libelektra: yajl: Elektra's boolean not supported
Steps to Reproduce the Problem
kdb mount config.json user/tests/yajl yajl type
kdb set user/tests/yajl true
kdb setmeta user/tests/yajl type boolean
kdb set user/tests/yajl 1
kdb rm user/tests/yajl
kdb umount user/tests/yajl
Expected Result
That still true is in the config file as true and 1 should be the same.
cat `kdb file user/tests/yajl`
#> true
Actual Result
Sorry, 1 warning was issued ;(
Warning (#78):
Description: Unknown or unsupported type found during streaming, assume key as string, type lost
Ingroup: plugin
Module: yajl
At: /home/jenkins/workspace/libelektra_master-Q2SIBK3KE2NBEMJ4WVGJXAXCSCB77DUBUULVLZDKHQEV3WNDXBMA/libelektra/src/plugins/yajl/yajl_gen.c:166
Reason: got boolean which is neither true nor false
Mountpoint: user/tests/yajl
Configfile: /home/markus/.config/config.json.26097:1554202289.309349.tmp
Set string to "1"
cat `kdb file user/tests/yajl`
#> "1"
System Information
- Elektra Version: master
Implementation Hint
The yajl plugin needs to:
- render Elektra’s “0” and “1” values to JSON’s false and true.
- fail with type errors if non-supported types are found
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24 (24 by maintainers)
Commits related to this issue
- yajl: Support elektra booleans fixes #2571 — committed to PhilippGackstatter/libelektra by deleted user 5 years ago
Yep, just add it to the contract key set. For example, the following line shows how YAML CPP configures the
typeplugin:https://github.com/ElektraInitiative/libelektra/blob/5519cb8066a096215a3701ca3d8c02fcebe54914/src/plugins/yamlcpp/yamlcpp.cpp#L44 .
I think it should just be
config/neednotinfos/config/needs. I can’t verify it right now though.The header of the README is turned into lines of
keyNew, which you then include into the pluginsgetmethod. You could manually add stuff there, using the README is preferred, since it automatically provides documentation.No this is not supported by the type plugin, I didn’t know there was a use case for this.
IMO it also doesn’t make sense. The Elektra-way of representing a boolean is
0and1. If a storage format supports types, the conversion from the Elektra-representation to the representation of the storage format, should be done by the storage plugin. In the end the storage plugin for format X should be the bridge between Elektra and format X.Thank you both!
With #3012, the yajl plugin has the following behavior.
With the type plugin
Without the type plugin
Does that refer to when the type plugin is mounted or without?
In this last case, the behavior until now was that a warning is emitted.
I think this is still fine, since without the type plugin, there shouldn’t be type checking.
No. With #2582
yajl(or the user) just needs to make sure that the config fortypeeither containsbooleansarray andboolean/restore = #1orbooleansarray which contains"true"and"false"at position#Xandboolean/restore = #XYes, because the problem occurs, when the user changes the key value after
kdbGet.yajlhas no influence on that.But nevermind that, we need changes to the
typeplugin anyway, because if the user adds a new key, the metadata will not be present and the solution won’t work.yajlalso has to add the metadatacheck/boolean/true = trueandcheck/boolean/false = falseto each key withtype = boolean. Otherwise the problem forkdb set /some/key onmentioned above will occur.