Skip to content

fix(AIP-160): clarify unset field in traversal behavior#1469

Merged
noahdietz merged 8 commits intoaip-dev:masterfrom
noahdietz:aip-160-unset-traversal
Mar 14, 2025
Merged

fix(AIP-160): clarify unset field in traversal behavior#1469
noahdietz merged 8 commits intoaip-dev:masterfrom
noahdietz:aip-160-unset-traversal

Conversation

@noahdietz
Copy link
Copy Markdown
Collaborator

Clarify the expected behavior when a non-primitive field in a traversal operator's chain of fields is not set, it should be skipped i.e. not matched. This has been the expected behavior since inception, but was undocumented.

Internal bug http://b/388065878

@noahdietz noahdietz requested a review from a team as a code owner January 7, 2025 19:48
@noahdietz noahdietz requested a review from neomagus00 January 7, 2025 19:48
Comment thread aip/general/0160.md
**may** permit traversal to undefined keys on maps and structs, and **should**
document how it behaves in this situation.

When evaluating an expression involving a traversal, if any non-primitive field
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if the comparison is a "not equal" one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the comparison in that case, it is skipped, at least that is my understanding of the feedback I got from maintainers. Unset == no value comparison at all.

I believe this is because of the ambiguity of the intent in such a filter - do they want to filter for entries that have a set and a.b != "foo" OR do they want to filter for entries that either do not have a set or a set and a.b != "foo".

This is where a Has operator would come into play e.g. "has: a AND a.b != "foo""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense - but maybe it would be good to include an inequality in the list (or highlight it here) to make it clear? Basically, if I wasn't sure of the behavior without clarification, I suspect others may be in a similar position.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fair enough! I've included a sentence to this effect - same logic applies even when using != which would imply matching on empty values.

@aip-dev aip-dev deleted a comment from AKSHAY1469-gli Jan 13, 2025
@aip-dev aip-dev deleted a comment from AKSHAY1469-gli Jan 13, 2025
@noahdietz noahdietz requested review from jskeet and removed request for neomagus00 January 13, 2025 19:49
Copy link
Copy Markdown
Contributor

@jskeet jskeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, thanks :)

@noahdietz noahdietz merged commit f9c4bbf into aip-dev:master Mar 14, 2025
2 checks passed
@noahdietz noahdietz deleted the aip-160-unset-traversal branch March 14, 2025 17:10
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.

2 participants