Skip to content

Unable to assign nested structure into a null value #229

Answered by wwkimball
lkoniecz asked this question in Q&A
Discussion options

You must be logged in to vote

You've certainly found an edge-case in the code but I'm not sure my response is going to meet your expectation. I'm not even sure what should happen in this case because what you're attempting to do is to overwrite null with a map/hash. If your null were any other scalar, you'd get an appropriate error stating that yamlpath is unwilling to convert a scalar into a complex type. On the other hand, if your null were already a map/hash -- even an empty one -- you'd get the outcome you expect.

This is the expected behavior when attempting to convert a scalar into a complex data type:

$ echo "foo: var" | yaml-set --change=foo.bar.key --value=value
CRITICAL:  Cannot add PathSegmentTypes.KEY subr…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by lkoniecz
Comment options

You must be logged in to vote
1 reply
@wwkimball
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #228 on February 06, 2024 16:52.