-
Notifications
You must be signed in to change notification settings - Fork 94
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
Prevent validators from dropping diags #619
Prevent validators from dropping diags #619
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise this looks really good! Thank you, @skirsten 🚀
If you're interested, we could ensure there's covering unit testing for this by updating/duplicating unit testing like TestServerValidateProviderConfig/request-config-ProviderWithValidateConfig-diagnostic
to have multiple validators returning diagnostics.
To create changelog entries for this, you can create a .changelog/619.txt
file with contents such as:
```release-note:bug
datasource: Prevented `ConfigValidators` from unexpectedly modifying or removing prior validator diagnostics
```
```release-note:bug
provider: Prevented `ConfigValidators` from unexpectedly modifying or removing prior validator diagnostics
```
```release-note:bug
resource: Prevented `ConfigValidators` from unexpectedly modifying or removing prior validator diagnostics
```
…agnostics overwrites Reference: #619 Against current `main`: ``` --- FAIL: TestServerValidateDataSourceConfig (0.00s) --- FAIL: TestServerValidateDataSourceConfig/request-config-DataSourceWithConfigValidators-diagnostics (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/internal/fwserver/server_validatedatasourceconfig_test.go:301: unexpected difference: &fwserver.ValidateDataSourceConfigResponse{ - Diagnostics: diag.Diagnostics{diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}}, + Diagnostics: diag.Diagnostics{ + diag.ErrorDiagnostic{detail: "error detail 1", summary: "error summary 1"}, + diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}, + }, } --- FAIL: TestServerValidateProviderConfig (0.00s) --- FAIL: TestServerValidateProviderConfig/request-config-ProviderWithConfigValidators-diagnostics (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/internal/fwserver/server_validateproviderconfig_test.go:307: unexpected difference: &fwserver.ValidateProviderConfigResponse{ PreparedConfig: &{Raw: s`tftypes.Object["test":tftypes.String]<"test":tftypes.String<"tes`..., Schema: schema.Schema{Attributes: {"test": schema.StringAttribute{Required: true}}}}, - Diagnostics: diag.Diagnostics{diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}}, + Diagnostics: diag.Diagnostics{ + diag.ErrorDiagnostic{detail: "error detail 1", summary: "error summary 1"}, + diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}, + }, } --- FAIL: TestServerValidateResourceConfig (0.00s) --- FAIL: TestServerValidateResourceConfig/request-config-ResourceWithConfigValidators-diagnostics (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/internal/fwserver/server_validateresourceconfig_test.go:301: unexpected difference: &fwserver.ValidateResourceConfigResponse{ - Diagnostics: diag.Diagnostics{diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}}, + Diagnostics: diag.Diagnostics{ + diag.ErrorDiagnostic{detail: "error detail 1", summary: "error summary 1"}, + diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}, + }, } ```
Will handle the unit testing and changelog via: #622 |
Thank you @bflad for taking care of it 🙏 I had a quick look yesterday but did not find the time. |
…agnostics overwrites (#622) Reference: #619 Against current `main`: ``` --- FAIL: TestServerValidateDataSourceConfig (0.00s) --- FAIL: TestServerValidateDataSourceConfig/request-config-DataSourceWithConfigValidators-diagnostics (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/internal/fwserver/server_validatedatasourceconfig_test.go:301: unexpected difference: &fwserver.ValidateDataSourceConfigResponse{ - Diagnostics: diag.Diagnostics{diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}}, + Diagnostics: diag.Diagnostics{ + diag.ErrorDiagnostic{detail: "error detail 1", summary: "error summary 1"}, + diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}, + }, } --- FAIL: TestServerValidateProviderConfig (0.00s) --- FAIL: TestServerValidateProviderConfig/request-config-ProviderWithConfigValidators-diagnostics (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/internal/fwserver/server_validateproviderconfig_test.go:307: unexpected difference: &fwserver.ValidateProviderConfigResponse{ PreparedConfig: &{Raw: s`tftypes.Object["test":tftypes.String]<"test":tftypes.String<"tes`..., Schema: schema.Schema{Attributes: {"test": schema.StringAttribute{Required: true}}}}, - Diagnostics: diag.Diagnostics{diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}}, + Diagnostics: diag.Diagnostics{ + diag.ErrorDiagnostic{detail: "error detail 1", summary: "error summary 1"}, + diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}, + }, } --- FAIL: TestServerValidateResourceConfig (0.00s) --- FAIL: TestServerValidateResourceConfig/request-config-ResourceWithConfigValidators-diagnostics (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-framework/internal/fwserver/server_validateresourceconfig_test.go:301: unexpected difference: &fwserver.ValidateResourceConfigResponse{ - Diagnostics: diag.Diagnostics{diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}}, + Diagnostics: diag.Diagnostics{ + diag.ErrorDiagnostic{detail: "error detail 1", summary: "error summary 1"}, + diag.ErrorDiagnostic{detail: "error detail 2", summary: "error summary 2"}, + }, } ```
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. |
More info here: hashicorp/terraform-plugin-framework-validators#94
Basically, it just makes sure the validators cannot accidentally drop previous diags.