Skip to content

Conversation

@HarshCasper
Copy link
Contributor

A LocalStack user reported a 500 Internal Error when using the GetTransitGatewayRouteTablePropagations API with filters. The error occurred because the code treated route_table_propagation as a dictionary when it's a list of dictionaries.

2025-05-06 10:29:42     result = filter_resources(transit_gateway_route_tables, filters, attr_pairs)
2025-05-06 10:29:42              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-05-06 10:29:42   File "/opt/code/localstack/.venv/lib/python3.11/site-packages/moto/utilities/utils.py", line 97, in filter_resources
2025-05-06 10:29:42     len(attrs) == 3 and instance.get(attrs[2]) not in values
2025-05-06 10:29:42                         ^^^^^^^^^^^^
2025-05-06 10:29:42 AttributeError: 'list' object has no attribute 'get'

This PR fixed the filtering function, improved route table propagation iteration, and implemented multi-criteria resource matching. The solution was tested manually with AWS CLI, though the current tests are passing.

@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 4.76190% with 20 lines in your changes missing coverage. Please review.

Project coverage is 92.83%. Comparing base (570069d) to head (ef4e581).
Report is 77 commits behind head on master.

Files with missing lines Patch % Lines
moto/ec2/models/transit_gateway_route_tables.py 4.76% 20 Missing ⚠️

❌ Your patch status has failed because the patch coverage (4.76%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8880      +/-   ##
==========================================
- Coverage   92.85%   92.83%   -0.02%     
==========================================
  Files        1282     1282              
  Lines      111792   111811      +19     
==========================================
+ Hits       103804   103805       +1     
- Misses       7988     8006      +18     
Flag Coverage Δ
servertests 27.97% <0.00%> (-0.01%) ⬇️
unittests 92.81% <4.76%> (-0.02%) ⬇️

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.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Hi @HarshCasper! Change LGTM - but this will need some tests.

If you just want to fix the 500-error, then I'm happy to merge a smaller PR with just this change without any tests:

- if transit_gateway_route_table.id in transit_gateway_route_table_id
+ if transit_gateway_route_table.id == transit_gateway_route_table_id

@bblommers
Copy link
Collaborator

Hey @HarshCasper, I think this has been fixed in #8951, as that significantly simplifies the overall RouteTable logic.

I'll close this, but let me know if the issue still exists though.

@bblommers bblommers closed this Jun 15, 2025
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