ElektraInitiative / libelektra

Elektra serves as a universal and secure framework to access configuration settings in a global, hierarchical key database.
https://www.libelektra.org
BSD 3-Clause "New" or "Revised" License
208 stars 123 forks source link

Can't set value, `Did not find key ...` #4987

Closed fel115 closed 2 months ago

fel115 commented 1 year ago

After setting a new key/value to the database, elektra can't find the new created key.

kdb set -v user:/sw/libelektra/opensesame/#0/current/sensors/#0/loc "Weatherstation"; 
kdb get -v user:/sw/libelektra/opensesame/#0/current/sensors/#0/loc; 

opensesame: no process found
Create a new key user:/sw/libelektra/opensesame/#0/current/sensors/#0/loc with string "Weatherstation"
got 49 keys
searching user:/sw/libelektra/opensesame/#0/current/sensors/#0/loc, found: <nothing>
Did not find key 'user:/sw/libelektra/opensesame/#0/current/sensors/#0/loc'

With other values, it worked well. Could this be caused by the second #0?

I also described this issue in this issue of opensesame.

markus2330 commented 1 year ago

Thank you for reporting this problem!

#0 are the first entry for arrays, so they have a special meaning.

To make this issue reproducible we probably need a longer example, including the mounting of TOML (probably the bug is related to this).

@atmaxinger do you maybe have an idea?

fel115 commented 1 year ago

For some reason, it worked today. But then I tried to remove one entry in the array and it removed the whole array. I used kdb rm user:/sw/libelektra/opensesame/#0/current/sensors/locto remove the loc entry. But mounting works without an error

root@messstation:/home/olimex/opensesame/debian# kdb mount -vv /home/olimex/opensesame/files/opensesame.spec spec:/sw/libelektra/opensesame/#0/current ni
root@messstation:/home/olimex/opensesame/debian# kdb spec-mount -vv /sw/libelektra/opensesame/#0/current
Got mountpoint from spec:/sw/libelektra/opensesame/#0/current with 24 nodes, configfile: opensesame.toml and mountpoint: /sw/libelektra/opensesame/#0/current
root@messstation:/home/olimex/opensesame/debian# kdb mount -vv /home/olimex/opensesame/files/opensesame.state.spec spec:/state/libelektra/opensesame/#0/current ni
root@messstation:/home/olimex/opensesame/debian# kdb spec-mount -vv /state/libelektra/opensesame/#0/current ni
Got mountpoint from spec:/state/libelektra/opensesame/#0/current with 3 nodes, configfile: opensesame.state and mountpoint: /state/libelektra/opensesame/#0/current

TOML files used opensesame.spec and opensesame.stat.spec

markus2330 commented 1 year ago

it removed the whole array: this is probably another bug. Please give full descriptions of what exactly you did and only describe one bug per issue.

fel115 commented 1 year ago

@atmaxinger how can I add an array with kdb editor ..., I don't understand the syntax in this file. Is there any documentation about it? I wasn't able to find one.

markus2330 commented 1 year ago

@fel115 you can choose your own syntax, but better use toml to not run into conversation issues. man kdb editor should work, is this missing in our armhf Debian packages?

Btw. As last resort you can also directly edit ~/.config/opensesame.toml

fel115 commented 1 year ago

@markus2330 Thx, now I was able to open the editor with the toml-format. man kdb editor is working.

I tried to add the array by adding `sensors.#0.loc = "weatherstation" to the ~/.config/opensesame.toml file, but I get this error message:

Validation Syntactic: Line 1~(11:8-11:32): syntax error, unexpected COMMENT, expecting BARE_STRING or LITERAL_STRING or BASIC_STRING
markus2330 commented 1 year ago

I think you need to quote "#0", e.g. sensors."#0".loc = "Gaestezimmer". Use git checkout if you messed up the config to start again.

fel115 commented 1 year ago

I think you need to quote "#0", e.g. sensors."#0".loc = "Gaestezimmer". Use git checkout if you messed up the config to start again.

Perfect, now its working. Thx :relaxed:

github-actions[bot] commented 2 months ago

I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:

github-actions[bot] commented 2 months ago

I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart: