libelektra: YAJL: Plugin Does Not Save Value Directly Below Mountpoint

Steps to Reproduce the Problem

kdb mount config.json user/tests/yajl yajl
kdb set user/tests/yajl 'This May Be the Year I Disappear'
kdb ls user/tests/yajl
#> user/tests/yajl
kdb get user/tests/yajl 

Expected Result

The last command should print the text This May Be the Year I Disappear.

Actual Result

The last command prints an empty line.

System Information

  • Elektra Version: master
  • OS: macOS 10.13.6

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Do we now want to support RFC 7159? In my opinion supporting every data type at the top-level makes sense.

I fully agree.

They just store the text (without the key):

So let us implement the same with yajl.

That breaks a test in the yajl module

Which test? (see also below)

I wanted to check in first, if that would be an acceptable solution

It is easier to see if something is an acceptable solution if:

  • you created an PR (which will then run all test cases)
  • describe in a test and with examples which behavior you now want to implement

This example works for me with yajl. Am I missing something?

No, this example only demonstrates that {"", "some value"} is not an ideal way to represent the parentKey’s value.

Empty keys allow you to map documents like {“root”: {“”: “something”}}. How do you map this currently to a KeySet?

Seems like YAML CPP handles this data properly:

kdb mount config.yaml user/tests/yaml yamlcpp
printf '{"root": {"": "something"}}' > "$(kdb file user/tests/yaml)"
kdb ls user/tests/yaml
#> user/tests/yaml/root/%
kdb get user/tests/yaml/root/%
#> something

. I did not adapt the plugin for empty keys though. Just calling setBaseName in a storage plugin, using the correct string value (""), should be enough to support this feature.

I do not know anything else that is special about parent keys.

There is also nothing else special about it except that some configuration file formats do not have a way to simply describe a value without a key.

“empty keys” (%)

Empty keys allow you to map documents like {"root": {"": "something"}}. How do you map this currently to a KeySet?

I am not certain that this is the correct way for YAJL to handle the problem any more, since a valid JSON document seems to always require an array or object at the top-level.

This seems to have changed: https://stackoverflow.com/questions/13318420/is-a-single-string-value-considered-valid-json

In https://www.ietf.org/rfc/rfc7159.txt there are even examples showing that “only values” are allowed. But it seems like yajl does not support this… (yajl 2.1.0-2+b3 yields the error Expected “{” but found “"”)

With the feature from RFC 7159 we could map:

"some value" -> parent = “some value” {"", "some value"} -> parent/% = “some value”

But we would need to work around yajl then… (the ChangeLog also does not indicate that this feature was added later).

I think I can look into this as my first issue. Can you give me a few pointers where I should start to look @markus2330? Thanks.

So only set needs to be fixed?

As far as I can tell, yes.

Thank you for reporting the problem!

How would such a JSON document look like? We also need documentation for the special semantics of configuration files only containing the parent key.