Skip to content

Conversation

@SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Oct 29, 2025

Required to enable testing dependency changes on the v1.13 release branch that impact the backends (i.e. #37837)

Cherrypicking in the changes from #37509

Prior to this change s3 tests would fail due to the tests' expected diagnostics for comparison to actual diagnostics lacking tfdiags.SourceRange data:

--- FAIL: TestBackendConfig_DynamoDBEndpoint (5.66s)
    --- FAIL: TestBackendConfig_DynamoDBEndpoint/config_hostname (0.84s)
        backend_test.go:528: TestBackendConfig on *s3.Backend with configtesting.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("tf-test"), "endpoints":cty.ObjectVal(map[string]cty.Value{"dynamodb":cty.StringVal("dynamo.test")}), "key":cty.StringVal("state"), "region":cty.StringVal("us-west-1")}}
        backend_test.go:532: unexpected diagnostics difference:   tfdiags.Diagnostics{
            -   &tfdiags.attributeDiagnostic{
            -           diagnosticBase: tfdiags.diagnosticBase{
            -                   severity: s"Warning",
            -                   summary:  "Complete URL Expected",
            -                   detail:   "The value should be a valid URL containing at least a scheme and"...,
            -           },
            -           attrPath: cty.Path{cty.GetAttrStep{Name: "endpoints"}, cty.GetAttrStep{Name: "dynamodb"}},
            -           subject: &tfdiags.SourceRange{
            -                   Filename: "<TestWrapConfig>",
            -                   Start:    tfdiags.SourcePos{Line: 1, Column: 1},
            -                   End:      tfdiags.SourcePos{Line: 1, Column: 1},
            -           },
            -   },
            +   &tfdiags.attributeDiagnostic{
            +           diagnosticBase: tfdiags.diagnosticBase{
            +                   severity: s"Warning",
            +                   summary:  "Complete URL Expected",
            +                   detail:   "The value should be a valid URL containing at least a scheme and"...,
            +           },
            +           attrPath: cty.Path{cty.GetAttrStep{Name: "endpoints"}, cty.GetAttrStep{Name: "dynamodb"}},
            +   },
              }

Following this PR the tests pass, as the expected diagnostics match (comparison no longer expects tfdiags.SourceRange data):

$ TF_ACC=1 go test -count=1 ./...
ok      github.com/hashicorp/terraform/internal/backend/remote-state/s3 319.384s

Target Release

1.13.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

* Fix S3 backend test affected by making the Workspaces method return errors via diagnostics

* Address diagnostics comparison issues in test by ensuring expected diagnostics are defined in the context of the config they're triggered by

* Fix failing test case `TestBackendConfig_EC2MetadataEndpoint/envvar_invalid_mode` by making `diagnosticBase` struct comparable

* Add compile-time checks that diagnostic types fulfil interfaces

* Stop diagnosticBase implementing ComparableDiagnostic, re-add S3-specific comparer code to s3 package

* Update tests to use the S3-specific comparer again

* Fix test case missed in refactoring
@SarahFrench SarahFrench marked this pull request as ready for review October 29, 2025 11:44
@SarahFrench SarahFrench requested review from a team as code owners October 29, 2025 11:44
@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Oct 29, 2025
@SarahFrench SarahFrench merged commit 595accb into v1.13 Oct 29, 2025
17 of 19 checks passed
@SarahFrench SarahFrench deleted the 1.13-backport-s3-test-fixes branch October 29, 2025 12:11
@github-actions
Copy link
Contributor

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 Nov 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants