Add validation to provider fields in both SDK and PF implementations of provider schema #6358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Closes hashicorp/terraform-provider-google#14447
This PR adds explicit validation feedback to users, to accompany the changes in GoogleCloudPlatform/magic-modules#9014
The PR above means that
""
values will be processed by all the usual provider configuration logic but the error messages returned to users may be confusing and result in GitHub issues being opened. By adding explicit validation users will be able to identify and address the problems themselves.I've chosen to add empty string validation to the more popular fields and avoiding things like
request_reason
because I don't know if there's a valid use case for setting that value to an empty string or not?Testing
I've added:
Here's a screenshot from a manual test. NOTE: there are always 2 errors, as both the SDK and PF validators are rejecting the bad input
Misc details
Previously I thought that provider-level validation protecting against empty strings was a problem due to the SDK being weird/making it easy to footgun when handling zero values. After some manual tests I found this wasn't the case, so added anti-empty string validation to the SDK and PF versions of the provider config code.
NOTE: If validation exists on one version of the provider config but not the other then there's a fundamental error in the provider, as provider schemas must match when muxed together.
Release Note Template for Downstream PRs (will be copied)
Derived from GoogleCloudPlatform/magic-modules#9050