Skip to content
8 changes: 8 additions & 0 deletions aip/general/0160.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ 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
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.

in the chain is not set on the entry being evaluated, the entry **should** be
skipped i.e. not match the filter expression. This applies even when the
comparison is a `!=`, which would imply matching on empty values. 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 +231,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.