hashicorp / hashicorp/terraform-plugin-sdk

Consolidate ConflictsWith errors

Open
#286 2 comments 1 reaction 0 assignees View on GitHub
enhancement terraform-plugin-framework upstream-terraform
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

### SDK version

```
v1.4.0
```

### Use-cases

Have a single error message for two related ConflictsWith fields- see https://github.com/terraform-providers/terraform-provider-google/issues/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

https://github.com/terraform-providers/terraform-provider-google/issues/5284

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.