Skip to content

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

Merged
Vonng merged 2 commits into
pgsty:mainfrom
yupoet:fix/putobject-checksum-error-message-226
Oct 15, 2026
Merged

Vonng merged 2 commits 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

yupoet and others added 2 commits September 26, 2026 20:37
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
@Vonng
Vonng merged commit 721dbfd into pgsty:main Oct 15, 2026
7 of 8 checks passed
Vonng added a commit that referenced this pull request Oct 15, 2026
Embed the Console versioning error fix at e5b165e4c0ee and add regression coverage for the algorithm-specific checksum messages merged in #229. Go CI, vulnerability checks, DCO and release-pipeline validation passed; the actual embedded Console and S3 checksum responses were also verified locally.

Fixes #231.

Signed-off-by: Feng Ruohang <[email protected]>
@Vonng Vonng added this to the 20261018 milestone Oct 19, 2026
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

2 participants