Skip to content

Fix index check for list in utilities.py#9728

Merged
bpandola merged 4 commits intogetmoto:masterfrom
knap1930:patch-1
Mar 11, 2026
Merged

Fix index check for list in utilities.py#9728
bpandola merged 4 commits intogetmoto:masterfrom
knap1930:patch-1

Conversation

@knap1930
Copy link
Contributor

@knap1930 knap1930 commented Feb 9, 2026

moto throws a IndexError: list index out of range when specifying a list index in ProjectionExpression that matches the length of the list, so if you try select [0] for an empty list, or [1] for a list with 1 element in it.

data = []
len(data) == 0
data[0] -> IndexError: list index out of range

Copy link
Collaborator

@bpandola bpandola left a comment

Choose a reason for hiding this comment

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

Let's add a test case (fails before your change, succeeds after) that covers this scenario. Thanks.

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (c7b3d3c) to head (6f9bab8).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9728   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files        1308     1308           
  Lines      118884   118884           
=======================================
+ Hits       110706   110707    +1     
+ Misses       8178     8177    -1     
Flag Coverage Δ
servertests 28.89% <ø> (ø)
unittests 93.09% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bpandola bpandola merged commit 9f4ba8c into getmoto:master Mar 11, 2026
71 checks passed
@bpandola bpandola added this to the 5.2 milestone Mar 11, 2026
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.

3 participants