Skip to content

fix: handle zero max_items_evaluated in DynamoDB read_items - #3417

Merged
kukushking merged 1 commit into
aws:mainfrom
hsusul:fix/dynamodb-read-items-zero-limit
Jul 31, 2026
Merged

fix: handle zero max_items_evaluated in DynamoDB read_items#3417
kukushking merged 1 commit into
aws:mainfrom
hsusul:fix/dynamodb-read-items-zero-limit

Conversation

@hsusul

@hsusul hsusul commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Feature or Bugfix

  • Bugfix

Detail

Fixes an issue in awswrangler.dynamodb.read_items where setting max_items_evaluated=0 was evaluated as a falsey truthiness check (if max_items_evaluated: and if limit:) rather than an explicit is not None check.

This resulted in two bugs when max_items_evaluated=0 was provided:

  1. read_items raised exceptions.InvalidArgumentCombination stating that at least one read argument (like max_items_evaluated) must be provided, even though max_items_evaluated was explicitly passed.
  2. If allow_full_scan=True was also provided alongside max_items_evaluated=0, max_items_evaluated=0 was ignored and all items in the DynamoDB table were scanned/queried without any limit.

Changes:

  • Update max_items_evaluated argument validation in read_items() and _read_items() to check is not None.
  • For max_items_evaluated=0, return an empty DataFrame (or empty list/iterator based on as_dataframe and chunked arguments) directly without executing unnecessary network/scan requests or violating botocore parameter validation limits.
  • Raise InvalidArgumentValue if max_items_evaluated < 0.
  • Add regression tests in tests/unit/test_moto.py.

Relates

  • N/A

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kukushking
kukushking merged commit 897e6eb into aws:main Jul 31, 2026
28 checks passed
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