Skip to content

tfsdk+types: Fix ObjectType missing attribute error and PathMatches schema validation #602

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

Merged
merged 2 commits into from
Dec 23, 2022

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 22, 2022

Closes #600

This change will move the PathMatches expression to schema validation to be performed upfront and allow zero matches to be returned. Previously, valid expressions could be rejected errantly in cases of empty collection type values where the expression steps traversed deeper. Consumers of PathMatches should not be returned errors in those cases and instead will receive zero path matches, which they can choose whether that result is significant or not. Invalid expressions for the schema will still receive errors.

While implementing the new expression to schema validation logic, the basetypes.ObjectType implementation was missing an error return for missing attributes which caused false positives. This was actually noticed previously, however a covering issue was not created to fix the behavior, but it is now being fixed as part of correctly implementing the expression to schema validation. Returning an error in this situation is considered the valid implementation detail as object types are statically defined based on the underlying map of attribute names to attribute types. It is never valid to step into a non-existent attribute name.

…chema validation

Reference: #600

This change will move the `PathMatches` expression to schema checking to be performed upfront and allow zero matches to be returned. Previously, valid expressions could be rejected errantly in cases of empty collection type values where the expression steps traversed deeper. Consumers of `PathMatches` should not be returned errors in those cases and instead will receive zero path matches, which they can choose whether that result is significant or not. Invalid expressions for the schema will still receive errors.

While implementing the new expression to schema validation logic, the `basetypes.ObjectType` implementation was missing an error return for missing attributes which caused false positives. This was actually noticed previously, however a covering issue was not created to fix the behavior, but it is now being fixed as part of correctly implementing the expression to schema validation. Returning an error in this situation is considered the valid implementation detail as object types are statically defined based on the underlying map of attribute names to attribute types. It is never valid to step into a non-existent attribute name.
@bflad bflad added the bug Something isn't working label Dec 22, 2022
@bflad bflad requested a review from a team as a code owner December 22, 2022 21:12
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@bflad bflad added this to the v1.1.0 milestone Dec 23, 2022
@bflad bflad merged commit 51bb0a7 into main Dec 23, 2022
@bflad bflad deleted the bflad/path-expression-matching-validation branch December 23, 2022 15:50
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

path: Valid Expressions for the Schema with No Matches Should Not Return Error
2 participants