Skip to content

fix(dynamodb): align size() type semantics with AWS#672

Merged
vieiralucas merged 1 commit intomainfrom
fix/dynamodb-size-numeric
Apr 22, 2026
Merged

fix(dynamodb): align size() type semantics with AWS#672
vieiralucas merged 1 commit intomainfrom
fix/dynamodb-size-numeric

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 22, 2026

Summary

  • attribute_size returned string-length for N-type attributes, so size(count) = :ten with count = N("10") and :ten = N("10") evaluated to false ("10".len() == 2, not 10). That isn't AWS behavior: size() is defined only for S, B, SS, NS, BS, L, and M; on N, BOOL, or NULL it's a type mismatch that silently filters the row out in FilterExpression context.
  • Drop the N and BOOL/NULL branches of attribute_size so size() returns None on those types, which flows to false in the filter evaluator.
  • Unignore filter_functions_with_sdk_space_before_paren: switch count from N("10") to S("1234567890") so size() still returns 10 and exercises both the size(X) and size (X) spacings.
  • Add filter_size_on_numeric_is_invalid locking the new semantics (size on N, BOOL, and a missing attribute all evaluate to false).

Test plan

  • cargo test -p fakecloud-dynamodb --lib
  • cargo test -p fakecloud-e2e --test dynamodb
  • cargo clippy -p fakecloud-dynamodb --all-targets -- -D warnings
  • cargo fmt --all

Summary by cubic

Fixes DynamoDB size() evaluation to match AWS: it’s only valid for S, B, SS, NS, BS, L, and M. On N, BOOL, or NULL it now evaluates to false in filters, avoiding incorrect matches.

  • Bug Fixes
    • Removed N/BOOL/NULL handling in attribute_size so size() returns None for those types.
    • Unignored filter_functions_with_sdk_space_before_paren; switched count to S("1234567890") to keep size() = 10 for both size(X) and size (X).
    • Added filter_size_on_numeric_is_invalid to assert false for size() on N, BOOL, and missing attributes.

Written for commit 3fef3f6. Summary will update on new commits.

- attribute_size returned string-length for N-type attributes, which made
  size(count_n) = :10 evaluate to true with count_n = 10 because "10".len() == 2
  is... not 10. That's not AWS behavior: size() is defined only for S, B, SS,
  NS, BS, L, and M. On N, BOOL, or NULL it is a type mismatch.
- Drop the N and BOOL/NULL branches of attribute_size so size() returns None
  on those types, which surfaces as false in FilterExpression (AWS's silent
  filter-out on type mismatch).
- Unignore filter_functions_with_sdk_space_before_paren: switch `count` from
  N("10") to S("1234567890") so size() still returns 10 and exercises both
  the `size(X)` and `size (X)` spacings.
- Add filter_size_on_numeric_is_invalid to lock the type-mismatch semantics
  (size on N, BOOL, and missing attributes all evaluate to false).
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@vieiralucas vieiralucas merged commit 30f640e into main Apr 22, 2026
48 checks passed
@vieiralucas vieiralucas deleted the fix/dynamodb-size-numeric branch April 22, 2026 16:18
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.

1 participant