Skip to content

fix(dynamodb): reject empty sets and non-string map keys in TypeSerializer#4741

Open
r266-tech wants to merge 1 commit intoboto:developfrom
r266-tech:fix-dynamodb-type-serializer
Open

fix(dynamodb): reject empty sets and non-string map keys in TypeSerializer#4741
r266-tech wants to merge 1 commit intoboto:developfrom
r266-tech:fix-dynamodb-type-serializer

Conversation

@r266-tech
Copy link
Copy Markdown

Fixes

Changes

boto3/dynamodb/types.py

  • _is_type_set: Added len(value) > 0 check to prevent vacuous truth matching empty sets
  • _serialize_m: Added validation that all map keys are str before serialization

tests/unit/dynamodb/test_types.py

  • Added test_serialize_empty_set_raises_error
  • Added test_serialize_map_with_non_string_key_raises_error

Testing

All 41 tests in test_types.py pass.

…lizer

- _is_type_set now checks len(value) > 0 to prevent vacuous truth
  matching empty sets, which produce invalid {'NS': []} that DynamoDB
  rejects (fixes boto#4738)
- _serialize_m now validates all map keys are strings before
  serialization, raising TypeError for non-string keys that would
  produce confusing errors later (fixes boto#4739)

Both fixes raise TypeError with clear messages at serialization time
rather than letting invalid data reach the DynamoDB API.
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.

2 participants