Skip to content

Fix issue where path in walk would get mutated#7657

Merged
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:fix-7656
Jun 4, 2025
Merged

Fix issue where path in walk would get mutated#7657
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:fix-7656

Conversation

@anderseknert
Copy link
Copy Markdown
Member

I'm still not sure where this mutation occurs, as the append operation done in walk returns a copy and shouldn't mutate. But at least creating a shallow copy rather than a slice fixes the issue, and is still quite performant compared to the previous implementation that did a deep-copy of the path in each iteration.

Fixes #7656

I'm still not sure where this mutation occurs, as the append operation
done in `walk` returns a copy and shouldn't mutate. But at least creating
a shallow copy rather than a slice fixes the issue, and is still quite
performant compared to the previous implementation that did a deep-copy
of the path in each iteration.

Fixes open-policy-agent#7656

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert merged commit 9d0557b into open-policy-agent:main Jun 4, 2025
28 checks passed
johanfylling pushed a commit to johanfylling/opa that referenced this pull request Jun 4, 2025
)

I'm still not sure where this mutation occurs, as the append operation
done in `walk` returns a copy and shouldn't mutate. But at least creating
a shallow copy rather than a slice fixes the issue, and is still quite
performant compared to the previous implementation that did a deep-copy
of the path in each iteration.

Fixes open-policy-agent#7656

Signed-off-by: Anders Eknert <anders@styra.com>
(cherry picked from commit 9d0557b)
johanfylling pushed a commit that referenced this pull request Jun 4, 2025
I'm still not sure where this mutation occurs, as the append operation
done in `walk` returns a copy and shouldn't mutate. But at least creating
a shallow copy rather than a slice fixes the issue, and is still quite
performant compared to the previous implementation that did a deep-copy
of the path in each iteration.

Fixes #7656

Signed-off-by: Anders Eknert <anders@styra.com>
(cherry picked from commit 9d0557b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected behavior with walk path as key in object comprehension

2 participants