Repository navigation
REST: Send x-amz-content-sha256 for SigV4 requests with a body - #4586
Merged
Merged
Conversation
The SigV4 adapter sets x-amz-content-sha256 only for requests without a body. Requests with a body (create namespace or table, commits, renames) go out without it, and REST catalogs that require the header reject them. Iceberg Java sends the header on every request. Set it to the hex SHA256 of the body. botocore's SigV4Auth signs this header's value as the payload hash when it is present, so the header and the signature stay consistent, as in standard SigV4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fokko
approved these changes
Dec 2, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks @plusplusjiajia! Sending the payload hash on every SigV4 request matches what Java does, and the test asserting the header equals botocore's signed payload hash is a nice touch. Verified locally: 207 unit tests pass, ruff clean, and the header matches the canonical request's payload hash for bytes, str and empty bodies. 🚀
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
Follow-up to #2827. The SigV4 adapter sets
x-amz-content-sha256only for requests without a body. Requests with a body (create namespace or table, commits, renames) go out without it, and REST catalogs that require the header reject them. For example, Alibaba Cloud DLF's Iceberg REST catalog answers400 BadRequestException: no header x-amz-content-sha256, so with PyIceberg 0.12.0 every write against it fails while reads work. Iceberg Java sends the header on every request.This PR sets the header on every request to the hex SHA256 of the body. botocore's
SigV4Authsigns this header's value as the payload hash when the header is present, so the header and the signature stay consistent, as in standard SigV4 (S3 requires the same header with the same value).This is a minimal subset of #3120. The canonical request is built exactly as before. The header uses hex, as standard SigV4 and the AWS reference implementation do, rather than the base64 value that Iceberg Java's flexible-checksum signer writes into it (discussed in #3120). The change is small, so it rebases easily onto the SigV4 extraction in #3410 / #4493 whichever lands first.
Are these changes tested?
Yes.
test_sigv4_sign_request_with_bodynow checks the exact header value, instead of only checking that it is not the empty-body hash.test_sigv4_content_sha256_header_is_the_signed_payload_hashchecks, for bytes, str and empty bodies, that the header equals the payload hash botocore computes from the body and that it is the payload hash in the signed canonical request. Without the change topyiceberg/catalog/rest/__init__.py, the bytes and str cases fail.pytest tests/catalog/test_rest.py -m unit: 207 passed.prek runon the changed files (ruff, ruff-format, mypy, codespell) passes.ap-southeast-1): onmain,create_namespaceandcreate_tablefail withno header x-amz-content-sha256. With this change, creating a namespace and a partitioned table, append, overwrite, delete, upsert, schema update, tags, time travel, property updates, rename and drop all succeed. Not tested against AWS Glue or S3 Tables.Are there any user-facing changes?
SigV4-signed requests with a body now carry
x-amz-content-sha256. A value set through theheader.x-amz-content-sha256catalog property is replaced by the computed hash, as it already was for requests without a body.🤖 Generated with Claude Code