Problem
Key-affinity routing for DynamoDB binary (B) partition keys hashes the value returned from the parsed botocore JSON request body. Botocore serializes binary values as base64 strings in JSON, so the affinity code hashes the base64 text bytes instead of the original binary value.
That can route binary partition keys to a different affinity node than the intended cross-language binary-key hash.
Evidence
A real botocore prepared PutItem with Item={"pk": {"B": b"\x00\x01stable"}} serializes to:
Current code:
alternator/core/key_affinity.py: _extract_typed_value() returns the raw parsed JSON value.
alternator/core/hashing.py: hash_attribute_value("B", value) encodes string values directly, so the base64 text is hashed.
tests/unit/test_key_affinity.py passes raw bytes, so it does not match real prepared-request shape.
Expected behavior
For B attributes parsed from request JSON, decode base64 text back to bytes before hashing. Raw bytes values should remain supported for direct/internal callers.
Test coverage needed
Add a test using a real botocore prepared request with a binary key and assert affinity selection matches hashing the original bytes, not the base64 string.
Problem
Key-affinity routing for DynamoDB binary (
B) partition keys hashes the value returned from the parsed botocore JSON request body. Botocore serializes binary values as base64 strings in JSON, so the affinity code hashes the base64 text bytes instead of the original binary value.That can route binary partition keys to a different affinity node than the intended cross-language binary-key hash.
Evidence
A real botocore prepared
PutItemwithItem={"pk": {"B": b"\x00\x01stable"}}serializes to:{"B": "AAFzdGFibGU="}Current code:
alternator/core/key_affinity.py:_extract_typed_value()returns the raw parsed JSON value.alternator/core/hashing.py:hash_attribute_value("B", value)encodes string values directly, so the base64 text is hashed.tests/unit/test_key_affinity.pypasses rawbytes, so it does not match real prepared-request shape.Expected behavior
For
Battributes parsed from request JSON, decode base64 text back to bytes before hashing. Rawbytesvalues should remain supported for direct/internal callers.Test coverage needed
Add a test using a real botocore prepared request with a binary key and assert affinity selection matches hashing the original bytes, not the base64 string.