fix: incorrect S3 backend checksum error message logic in resolutionMsg() #37926
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
Fixed a logic error in the
badChecksumError.resolutionMsg()method in the S3 backend that was checking and displaying the wrong checksum value. I noticed this when my checksum values got messed up in DynamoDB and I had to go in manually to fix them. Fortunately the output provided the correct checksum value, just not in the right place.Changes Made
File:
internal/backend/remote-state/s3/client.goIn the
resolutionMsg()method (lines ~715-729), corrected two issues:if len(err.digest) > 0toif len(err.expected) > 0%x,err.digestto%x,err.expectedRationale
The error resolution message should guide users based on whether DynamoDB has a stored expected checksum, not based on whether S3 calculated an actual digest. The logic determines:
err.expectedhas a value: DynamoDB has a stored checksum that likely needs updating → tell user what the correct value should beerr.expectedis empty: DynamoDB has no/empty checksum → tell user to remove or verify the digest entryThe previous implementation incorrectly used
err.digest(the calculated checksum from S3 state data) instead oferr.expected(the stored checksum from DynamoDB), which could provide incorrect guidance to users troubleshooting checksum mismatch errors.Example Scenario
Consider a case where:
abc123(err.digest)[](err.expected)Before (incorrect):
len(err.digest) > 0→ trueabc123After (correct):
len(err.expected) > 0→ falseFixes #
Target Release
1.15.x
Rollback Plan
Changes to Security Controls
No changes to security controls. This is a bug fix to error message logic only. The fix ensures users receive correct troubleshooting guidance but does not affect access controls, encryption, or logging functionality.
CHANGELOG entry
Changelog summary: