Skip to content

Conversation

SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Sep 11, 2025

Follow up to #37589. In that case, the interface defining the StateMgr method was updated to return diagnostics instead of errors, and something went wrong when that change was pulled into a long-lived feature branch.

This PR changes that code and other examples of calling code to handle diagnostics more conventionally:

  • Instead of checking for non-nil values, inspect for errors
  • Retrieve an error representation of the diagnostics where calling code previously used errors to make test failure messages or return errors to users.

Target Release

N/A

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.

@SarahFrench SarahFrench requested a review from a team as a code owner September 11, 2025 15:36
@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Sep 11, 2025
@SarahFrench SarahFrench marked this pull request as draft September 11, 2025 15:37
@SarahFrench SarahFrench changed the title Update call to StateMgr method to use diagnostics more explicitly Update calls to StateMgr method to use diagnostics more conventionally Sep 11, 2025
@SarahFrench SarahFrench marked this pull request as ready for review September 12, 2025 15:47
@SarahFrench SarahFrench requested review from a team as code owners September 12, 2025 15:47
@SarahFrench
Copy link
Member Author

s3 tests:

$ go test -v github.com/hashicorp/terraform/internal/backend/remote-state/s3

 ...omitted test output...

--- PASS: TestValidateDuration (0.00s)
    --- PASS: TestValidateDuration/valid (0.00s)
    --- PASS: TestValidateDuration/fails_validator (0.00s)
    --- PASS: TestValidateDuration/invalid (0.00s)
--- PASS: TestValidateSetStringElements (0.00s)
    --- PASS: TestValidateSetStringElements/valid (0.00s)
    --- PASS: TestValidateSetStringElements/fails_validator (0.00s)
PASS
ok      github.com/hashicorp/terraform/internal/backend/remote-state/s3 306.447s

@SarahFrench
Copy link
Member Author

I can't run the kubernetes tests using the usual method, as I think ToB has removed docker from my laptop.

gcs tests:

$ go test -v github.com/hashicorp/terraform/internal/backend/remote-state/gcs

...removed output here...

--- PASS: TestAccBackendWithCustomerSuppliedEncryption (19.44s)
=== NAME  TestAccBackend
    testing.go:303: TestBackend: testing state locking for *gcs.Backend
2025/09/12 17:35:29 Object deleted: bar.tfstate
2025/09/12 17:35:30 Object deleted: default.tfstate
--- PASS: TestAccBackendWithCustomerManagedKMSEncryption (22.29s)
2025/09/12 17:35:34 Object deleted: bar.tfstate
2025/09/12 17:35:35 Object deleted: default.tfstate
--- PASS: TestAccBackend (27.45s)
PASS
ok      github.com/hashicorp/terraform/internal/backend/remote-state/gcs        86.411s

Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@SarahFrench
Copy link
Member Author

Thanks!

@SarahFrench SarahFrench merged commit 6847e76 into main Sep 15, 2025
7 checks passed
@SarahFrench SarahFrench deleted the sarah/fixup-post-interface-change branch September 15, 2025 14:23
@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 Oct 16, 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