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

Add Attribute Path for Type Validator Diagnostics #127

Closed
bflad opened this issue Sep 3, 2021 · 1 comment · Fixed by #129
Closed

Add Attribute Path for Type Validator Diagnostics #127

bflad opened this issue Sep 3, 2021 · 1 comment · Fixed by #129
Assignees
Labels
enhancement New feature or request

Comments

@bflad
Copy link
Contributor

bflad commented Sep 3, 2021

Module version

Pre v0.3.0 with validators support

Use-cases

Diagnostics from attr.TypeWithValidate Validate() methods should have the opportunity to return the attribute path associated with the diagnostic, to ensure the feedback is clear for practitioners and provider developers.

Attempted Solutions

Currently diagnostics must must manually re-associate the value as a string or establish a meaningful context in the diagnostic summary/detail.

Proposal

Before releasing v0.3.0, make the breaking change to add *tftypes.AttributePath to the attr.TypeWithValidate interface type Validate() method signature:

type TypeWithValidate interface {
	Type

	Validate(context.Context, tftypes.Value, *tftypes.AttributePath) []*tfprotov6.Diagnostic
}

All Validate() calling code currently has access to the *tftypes.AttributePath.

Other changes from #24 and #81 may further change this method signature.

References

Found while looking at #53 and #99.

@bflad bflad added the enhancement New feature or request label Sep 3, 2021
@bflad bflad self-assigned this Sep 3, 2021
@bflad bflad changed the title Add Attribute Path for Validator Diagnostics Add Attribute Path for Type Validator Diagnostics Sep 3, 2021
bflad added a commit that referenced this issue Sep 3, 2021
bflad added a commit that referenced this issue Sep 7, 2021
bflad added a commit that referenced this issue Sep 7, 2021
bflad added a commit that referenced this issue Sep 7, 2021
@bflad bflad closed this as completed in #129 Sep 7, 2021
bflad added a commit that referenced this issue Sep 7, 2021
@github-actions
Copy link

github-actions bot commented Oct 8, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, 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 Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
1 participant