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

Fix configvalidator dropping previous diags #94

Closed
wants to merge 1 commit into from

Conversation

skirsten
Copy link

Before if you had something like this

return []resource.ConfigValidator{
  resourcevalidator.ExactlyOneOf(
    path.MatchRoot("a"),
    path.MatchRoot("b"),
  ),
  resourcevalidator.ExactlyOneOf(
    path.MatchRoot("c"),
    path.MatchRoot("d"),
  ),
}

the second validator overwrites the diags from the first one, ignoring it completely.

Alternatively this could also be fixed in the framework itself like here:

for _, blockValidator := range block.SetValidators() {
  // Instantiate a new response for each request to prevent validators
  // from modifying or removing diagnostics.

@skirsten skirsten requested a review from a team as a code owner January 11, 2023 17:56
@hashicorp-cla
Copy link

hashicorp-cla commented Jan 11, 2023

CLA assistant check
All committers have signed the CLA.

@skirsten skirsten force-pushed the fix-configvalidator-diag branch from ab8b931 to 13adb17 Compare January 11, 2023 18:02
@bflad
Copy link
Contributor

bflad commented Jan 11, 2023

Hi @skirsten 👋 Thank you for submitting this!

Rather than expecting all validators to properly "passthrough" validation diagnostics, I think I agree with your second idea here of fixing the framework to treat each validator separately. Would you be willing to submit that fix upstream?

Thanks again. 😄

@bflad
Copy link
Contributor

bflad commented Jan 13, 2023

terraform-plugin-framework v1.1.0 has been released which should fix this. Thanks for the upstream fix, @skirsten!

@bflad bflad closed this Jan 13, 2023
@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 Feb 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants