Skip to content

all: Refactor schema validation to support type-specific logic and prevent AttributeTypes/ElementType field panics #706

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
Mar 30, 2023

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Mar 29, 2023

Reference: #574
Closes #699
Reference: #704
Reference: #705

The goal of this change is to enable easier schema validation within the framework logic. This is achieved by implementing new internal interfaces that implement shared logic across all schema types, then introduce methods on attribute types which currently implement type-specific validation logic.

The Schema type Validate() method deprecations are necessary to ensure that the framework logic can pass the available context.Context. While no framework logic is currently dependent on the context.Context, its possible that future logic may want to use tfsdklog.

The new ValidateImplementation() methods on attribute types, while technically exported, cannot be implemented externally due to their usage of internal types. This follows the existing implementation of the framework where attribute types already cannot be extended due to the Equal(fwschema.Attribute) method requirement. Therefore these new ValidateImplementation() methods do not need to worry about compatibility promises and can be modified or removed in the future.

This change also includes some breadcrumbs for other schema validation requests.

…event AttributeTypes/ElementType field panics

Reference: #574
Reference: #699
Reference: #704
Reference: #705

The goal of this change is to enable easier schema validation within the framework logic. This is achieved by implementing new internal interfaces that implement shared logic across all schema types, then introduce methods on attribute types which currently implement type-specific validation logic.

The new `ValidateImplementation()` methods on attribute types, while technically exported, cannot be implemented externally due to their usage of internal types. This follows the existing implementation of the framework where attribute types already cannot be extended due to the `Equal(fwschema.Attribute)` method requirement. Therefore these new `ValidateImplementation()` methods do not need to worry about compatibility promises and can be modified or removed in the future.

This change also includes some breadcrumbs for other schema validation requests.
@bflad bflad added bug Something isn't working tech-debt Issues tracking technical debt that we're carrying. labels Mar 29, 2023
@bflad bflad added this to the v1.3.0 milestone Mar 29, 2023
@bflad bflad requested a review from a team as a code owner March 29, 2023 17:17
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 merged commit d763289 into main Mar 30, 2023
@bflad bflad deleted the bflad/schema-validate-implementation branch March 30, 2023 14:36
@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 Apr 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working tech-debt Issues tracking technical debt that we're carrying.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

schema.MapAttribute struct without ElementType member causes segmentation fault
2 participants