Skip to content
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

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions aip/general/0160.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ the service **should** return an error with `INVALID_ARGUMENT`. A service
**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
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
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""

in the chain is not set on the entry being evaluated, the entry **should** be
skipped i.e. not match the filter expression. In the examples above, if resource
field `a` is not set on the resource instance, that instance is skipped as a
non-match.

**Important:** The `.` operator **must not** be used to traverse through a
repeated field or list, except for specific use with the `:` operator.

Expand Down Expand Up @@ -224,4 +230,5 @@ Schematic validation refers, but is not limited to, the following:

## Changelog

- **2025-01-07**: Clarify behavior for unset field in traversal operator chain.
- **2024-12-11**: Move non-compliant filter guidance to Validation section.
Loading