Skip to content

fix: name the checksum algorithm in PutObject/UploadPart mismatch errors #226 - #229

Open
yupoet wants to merge 1 commit into
pgsty:mainfrom
yupoet:fix/putobject-checksum-error-message-226
Open

yupoet wants to merge 1 commit into
pgsty:mainfrom
yupoet:fix/putobject-checksum-error-message-226

Conversation

@yupoet

@yupoet yupoet commented Sep 26, 2026

Copy link
Copy Markdown

Summary

PutObject/UploadPart checksum mismatches currently return the generic The provided 'x-amz-checksum' header does not match what was computed. This adds the algorithm name to the message, matching S3's wording (and the CompleteMultipartUpload behavior already aligned in #225):

The CRC32 you specified did not match the calculated checksum.
The CRC32C you specified did not match the calculated checksum.

Changes

  • internal/hash: ChecksumMismatch gains an Algorithm field; all four construction sites fill it via ChecksumType.String() (streaming reader mismatch, trailing-checksum decode failure, and both Checksum.Matches paths).
  • cmd/api-errors.go: toAPIError renders the algorithm-specific message when present; unknown algorithms keep the generic table description as fallback.
  • cmd/object-handlers-chunked-checksum_test.go: the wrong-CRC32 chunked case now also asserts the message (response body is parsed once — the previous shape consumed it in the code assertion first).

Testing

  • go test ./cmd/ -run 'Checksum|Digest' — ok (21.7s)
  • go test ./internal/hash/... — ok
  • gofmt clean

Fixes #226

hash.ChecksumMismatch now carries the requested algorithm (CRC32, CRC32C,
SHA1, SHA256, CRC64NVME), and toAPIError renders it S3-style:

  The CRC32 you specified did not match the calculated checksum.

instead of the generic "The provided 'x-amz-checksum' header does not match
what was computed.", for all four mismatch construction sites (streaming
reader, trailing-checksum decode, and both Checksum.Matches paths). Mirrors
the wording already shipped for CompleteMultipartUpload in pgsty#225.

Fixes pgsty#226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align PutObject checksum error messages with S3

1 participant