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

Make selector attributes stricter #946

Merged
merged 1 commit into from
Oct 20, 2021
Merged

Conversation

mtdowling
Copy link
Member

Selector attributes are curretly too permissive, and this makes it
harr to know when a selector is invalid. The original intent of making
selector attributes permissive was to make it possible to add new
attributes and nested attribute values without needing to version the
Smithy specification, but this looseness ended up making it really hard
to understand if you were using the current version of the specification
correctly.

For example, consider the following selector that previously worked:

[id|com.foo#Baz]

Smithy previoulsy would let this through, and it didn't emit any
warnings. This should have been:

[id=com.foo#Baz]

It's in our users' best interest for us to be stricer about attributes
so that they know when they use them incorrectly. Even as the designer
of selectors, I got this wrong, and struggled for about 20 minutes
trying to figure out why.

This change no longer allows wildcard access to top level shapes, the id
attribute, or the service attribute. While this is a breaking change,
it's a desirable breaking change that will only serve to reveal bugs in
selectors.

The following selecors are examples that will no longer work:

  • [id|com.foo#Baz] (invalid wildcard access of id)
  • [foo] (invalid top-level attribute)
  • [id|foo] (invalid wildcard access of id)
  • [service|foo] (invalid wildcard access of service)
  • [service|id|foo] (invalid wildcard access of id)

Attempting to access traits that do not exist, variables that do not
exist, values of traits or variables that do not exist, or to descend
into literal scalar values will continue to work and will continue to
return an empty value:

  • [id|name|foo] (descending into scalars is still ok. This might be a
    legitimate use case when using heterogenous projections, for example).
  • [vars|doesNotExist|nested] (accessing unknown variables is ok)
  • [service|id|name|foo] (descending into scalars is ok, even nested)
  • [trait|doesNotExist] (accessing wildcard traits, even unknown traits
    is ok).

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Selector attributes are curretly *too* permissive, and this makes it
harr to know when a selector is invalid. The original intent of making
selector attributes permissive was to make it possible to add new
attributes and nested attribute values without needing to version the
Smithy specification, but this looseness ended up making it really hard
to understand if you were using the current version of the specification
correctly.

For example, consider the following selector that previously worked:

```
[id|com.foo#Baz]
```

Smithy previoulsy would let this through, and it didn't emit any
warnings. This should have been:

```
[id=com.foo#Baz]
```

It's in our users' best interest for us to be stricer about attributes
so that they know when they use them incorrectly. Even as the designer
of selectors, I got this wrong, and struggled for about 20 minutes
trying to figure out why.

This change no longer allows wildcard access to top level shapes, the id
attribute, or the service attribute. While this _is_ a breaking change,
it's a desirable breaking change that will only serve to reveal bugs in
selectors.

The following selecors are examples that will no longer work:

* `[id|com.foo#Baz]` (invalid wildcard access of id)
* `[foo]` (invalid top-level attribute)
* `[id|foo]` (invalid wildcard access of id)
* `[service|foo]` (invalid wildcard access of service)
* `[service|id|foo]` (invalid wildcard access of id)

Attempting to access traits that do not exist, variables that do not
exist, values of traits or variables that do not exist, or to descend
into literal scalar values will continue to work and will continue to
return an empty value:

* `[id|name|foo]` (descending into scalars is still ok. This might be a
  legitimate use case when using heterogenous projections, for example).
* `[vars|doesNotExist|nested]` (accessing unknown variables is ok)
* `[service|id|name|foo]` (descending into scalars is ok, even nested)
* `[trait|doesNotExist]` (accessing wildcard traits, even unknown traits
  is ok).
@mtdowling mtdowling requested a review from a team as a code owner October 20, 2021 03:23
@mtdowling mtdowling merged commit d01067e into main Oct 20, 2021
@mtdowling mtdowling deleted the tighten-selector-attributes branch January 7, 2022 21:56
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