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

Prevent validators from dropping diags #619

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

skirsten
Copy link
Contributor

More info here: hashicorp/terraform-plugin-framework-validators#94

Basically, it just makes sure the validators cannot accidentally drop previous diags.

@skirsten skirsten requested a review from a team as a code owner January 11, 2023 18:25
@bflad bflad added the bug Something isn't working label Jan 11, 2023
@bflad bflad added this to the v1.1.0 milestone Jan 11, 2023
@bflad bflad self-assigned this Jan 11, 2023
Copy link
Contributor

@bflad bflad left a 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
```

bflad added a commit that referenced this pull request Jan 13, 2023
…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"},
            + 	},
              }
```
@bflad
Copy link
Contributor

bflad commented Jan 13, 2023

Will handle the unit testing and changelog via: #622

@bflad bflad merged commit beaf82a into hashicorp:main Jan 13, 2023
@skirsten
Copy link
Contributor Author

Thank you @bflad for taking care of it 🙏 I had a quick look yesterday but did not find the time.

bflad added a commit that referenced this pull request Jan 13, 2023
…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"},
            + 	},
              }
```
@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
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants