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

Consolidate ConflictsWith errors #286

Open
danawillow opened this issue Jan 2, 2020 · 2 comments
Open

Consolidate ConflictsWith errors #286

danawillow opened this issue Jan 2, 2020 · 2 comments
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework upstream-terraform

Comments

@danawillow
Copy link
Contributor

SDK version

v1.4.0

Use-cases

Have a single error message for two related ConflictsWith fields- see hashicorp/terraform-provider-google#5284.

Attempted Solutions

If two fields conflict with each other, we can get a single error message by only setting ConflictsWith on one of them, which works fine.

However, if three fields (A, B, and C) conflict with each other, we would have to set ConflictsWith on at least two of them in order to cover all cases (setting it only on A would mean that a user could set B and C together in their config), which means that a user could end up with two error messages.

Proposal

Consolidate error messages when possible. In the example in the related issue, instead of having both Error: "name_prefix": conflicts with name and Error: "name": conflicts with name_prefix, recognize that those two are the same and only return one of them. My guess is that we'd also want to do something similar to ExactlyOneOf and AtLeastOneOf.

References

hashicorp/terraform-provider-google#5284

@jsoref
Copy link

jsoref commented Jan 3, 2020

For my reference, this appears to be:

func validateConflictingAttributes(

@radeksimko
Copy link
Member

I agree with you @danawillow that these error messages and UX here could be improved.

The new "rich diagnostic errors/warnings" that came with 0.12 gave us the ability to carry helpful context alongside each message, so we can show the relevant snippet of code and point to the relevant line.

With that in mind we would need to tune this to allow us pointing to more than a single line of code, i.e. all conflicting fields, or we would need to arbitrarily pick one, which may confuse the user more than the current (verbose) messaging.

So aggregating the message itself is easy, aggregating the context is possible, but not as easy and we can't quite separate the two from each other as that is how errors & warnings are represented in the plugin protocol since 0.12.

@bflad bflad added the terraform-plugin-framework Resolved in terraform-plugin-framework label Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework upstream-terraform
Projects
None yet
Development

No branches or pull requests

4 participants