Files
floci/src/main/java
Kenshin Okinaka 3d3f12d912 fix(dynamodb): attach X-Amz-Crc32 header to JSON protocol responses (#347)
* fix(dynamodb): attach X-Amz-Crc32 header to JSON protocol responses

The AWS SDK for Go v2 DynamoDB client wraps every response body in a
CRC32-verifying reader and emits "failed to close HTTP response body,
this may affect connection reuse" on every call when the header is
missing. Real AWS DynamoDB includes this header on all responses.

Add it at the JSON protocol boundary (AwsJsonController) for both
DynamoDB and DynamoDBStreams, using a new DynamoDbResponses helper
that serializes the entity to bytes, computes the CRC32, and rebuilds
the Response with the bytes + header. Error responses are wrapped as
well to match real AWS behavior.

The wrapping lives in AwsJsonController rather than DynamoDbJsonHandler
because the handler is also invoked from CBOR, API Gateway proxy, and
Step Functions task flows — those callers must keep the original
ObjectNode entity.

Add unit tests for DynamoDbResponses and an integration test that
verifies the header is present and matches the CRC32 of the response
body bytes on both success and error responses.

* test(dynamodb): use explicit UTF-8 charset in DynamoDbResponsesTest

Address Copilot review comment on floci-io/floci#347: ".getBytes()"
uses the platform default charset, which can make the test (and the
computed CRC32) vary across environments. The string is ASCII so the
bytes are the same on any sensible platform, but being explicit about
UTF-8 makes the determinism obvious and matches the rest of the
codebase.
2026-04-11 11:27:32 -05:00
..