Repository navigation
Skip sequence comments when resolving numeric tree paths - #2344
Open
spicysharkco wants to merge 1 commit into
Open
spicysharkco wants to merge 1 commit into
spicysharkco wants to merge 1 commit into
Conversation
Numeric paths in YAML lists counted stored comments as list items. Extracting the second item could return the first, and set or unset could change the wrong item. Skip comments when mapping numeric path indices in extraction, set and unset. Add a regression test covering comment positions, nested paths and list bounds. Signed-off-by: spicysharkco <321699413+spicysharkco@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Encrypt this YAML with an age recipient:
sops decrypt --extract '["items"][1]' input.enc.yamlprintsfirst; the expected output issecond. With the same index[1],sops set input.enc.yaml '["items"][1]' '"replacement"'replacesfirst, andsops unset input.enc.yaml '["items"][1]'removesfirst.Numeric extraction indexes the internal slice, which also holds the list's comments. Set and unset use the same raw indices.
This change maps numeric path indices to positions that skip comments in all three operations, including nested paths. Comments stay where they are. Before,
[0]on this list printed the comment itself (value: ' primary',inline: false) and[2]printedsecond. Now[2]is out of bounds for extract and unset, and set appends.The new test fails without the change.