Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Mount example broken #3722

Closed
kodebach opened this issue Mar 23, 2021 · 0 comments · Fixed by #3805
Closed

Mount example broken #3722

kodebach opened this issue Mar 23, 2021 · 0 comments · Fixed by #3805
Labels

Comments

@kodebach
Copy link
Member

kodebach commented Mar 23, 2021

The mount configuration files example is broken.

In particular this part doesn't work:

# mount the backend with the plugins ...
kdb mount example.ni user:/example ni type

# ... and set a value for the demonstration
kdb set user:/example/enumtest/fruit apple
#> Create a new key user:/example/enumtest/fruit with string "apple"

[...]

kdb meta-set user:/example/enumtest/fruit check/type enum
kdb meta-set user:/example/enumtest/fruit check/enum "#2"
kdb meta-set user:/example/enumtest/fruit check/enum/#0 apple
kdb meta-set user:/example/enumtest/fruit check/enum/#1 banana
kdb meta-set user:/example/enumtest/fruit check/enum/#2 grape
kdb set user:/example/enumtest/fruit tomato
# RET:5
# this fails because tomato is not in the list of valid values

Instead of the expected results we get:

kdb meta-set user:/example/enumtest/fruit check/type enum
#> Sorry, module type issued the error C03200:
#> Validation Semantic: The type 'enum' failed to match for 'user:/example/enumtest/fruit' with string: 'apple'
#> No values are allowed (check/enum is an empty array, or parent isn't set to last element)

The problem here is, that with the kdb meta-set ... check/type enum line, we tell the type plugin to validate this key against an enum definition. However, we haven't set any enum values yet, so we basically tell type to ensure the key doesn't have a value. But we have already set a value for the key in question.

There are two solutions:

  1. Don't call kdb set before all the kdb meta-set lines. That way, the key doesn't have a value when type validates against the empty enum.
  2. Don't call kdb meta-set ... check/type enum before all the other kdb meta-set lines. Here the type plugin will only start validating the key when the enum definition is complete.

The example should be adapted to one of these two solutions.

@markus2330 markus2330 added the 1p one point label Mar 23, 2021
philippoppel pushed a commit to philippoppel/libelektra that referenced this issue Mar 23, 2021
philippoppel pushed a commit to philippoppel/libelektra that referenced this issue Mar 23, 2021
philippoppel pushed a commit to philippoppel/libelektra that referenced this issue Apr 22, 2021
philippoppel pushed a commit to philippoppel/libelektra that referenced this issue Apr 22, 2021
mpranj pushed a commit to mpranj/libelektra that referenced this issue Apr 22, 2021
mpranj pushed a commit that referenced this issue Apr 23, 2021
mpranj pushed a commit that referenced this issue Apr 23, 2021
mpranj pushed a commit that referenced this issue Apr 23, 2021
mpranj pushed a commit to mpranj/libelektra that referenced this issue Apr 23, 2021
mpranj pushed a commit to mpranj/libelektra that referenced this issue Apr 23, 2021
mpranj pushed a commit to mpranj/libelektra that referenced this issue Apr 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants