-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat: new jqPaths ignore differences field for dynamic field selection (#24599)
#24658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
puretension
wants to merge
6
commits into
argoproj:master
Choose a base branch
from
puretension:fix/jq-multiple-fields-24599
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b5b6a0d
fix: support jqPathExpressions that return multiple fields (#24599)
puretension 0711ef1
fix: replace interface{} with any and fix formatting
puretension 60472ed
fix: apply gofumpt formatting
puretension acc92fc
chore: trigger CI rebuild for formatting check
puretension 7798860
fix: resolve gofumpt formatting issues
puretension 310bf14
Implement jqPaths field using delpaths() instead of del()
puretension File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
fix: support jqPathExpressions that return multiple fields (#24599)
- Add detection for multi-value jq expressions in ignoreApplicationDifferences - Implement jqMultiPathNormalizerPatch for handling annotation key selections - Fix issue where expressions like '.metadata.annotations | keys[] | select(startswith(...))' failed - Add comprehensive test coverage for multiple field scenarios Fixes #24599 Signed-off-by: puretension <[email protected]>
- Loading branch information
commit b5b6a0d8d93f0386e2cae590905907f9cd178bf5
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think trying to infer the user's intent from the output of their expression is going to be too error-prone.
Consider this input:
{"a": 1, "b": "a", "c": [["a"]]}Suppose we decide that, if the user's query evaluates to a string, we're going to treat it as a path.
If the user passes this query:
.bthen we'll receive the value
"a", assume it's a path, and delete the"a"key from the input. But that's unintuitive. The user obviously wanted to delete the"b"key.We could be more strict and say that the user must produce a valid
delpaths()input, i.e. a[][]string.But if the input object actually contains a
[][]string, we have no way of knowing whether the user is trying to pass us paths or has directly targeted something they want to delete:.cOutput:
[["a"]]Did the user mean to delete the
.cfrom the object, or.a?tl;dr, I don't think we should reuse the
jqPathExpressionsfield. I think we should create a newjqPathsfield. It should be an array of queries that produce jq paths:So the solution to the user's problem would be something like:
Then we should use
delpaths()instead ofdel()to complete the mutation.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crenshaw-dev Thanks for the sharp analysis!
the examples with
.band.creally highlight how ambiguous and error-prone the current approach would be.I completely agree with your reasoning. I’ll follow your suggestion and introduce a new jqPaths field (array of jq path queries), and update the implementation to use delpaths() instead of del().
I’ll update the schema, implementation, tests, and docs accordingly. 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also added an item to the next Contributors' meeting to discuss w/ other maintainers. I'm always hesitant to add new features, so I want to make sure everyone feels its worth it.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this to the Contributors' meeting!
I've implemented the
jqPathsapproach you suggested.Happy to push it for reference during the discussion! we can always adjust based on the team's feedback.
Looking forward to hearing everyone's thoughts! 🙏