GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — APIGW: fix TestInvokeMethod 500 failures by bentsku · Pull Request #13207 · localstack/localstack

This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Conversation

@bentsku

@bentsku bentsku commented Sep 29, 2025

Copy link
Copy Markdown
Contributor

Motivation

As part of our weekly report, I've spotted 2 issues with APIGW TestInvokeMethod:

  File "/opt/code/localstack/.venv/lib/python3.13/site-packages/localstack/services/apigateway/next_gen/execute_api/test_invoke.py", line 263, in run_test_invocation
    log = log_template(invocation_context, response_headers)
  File "/opt/code/localstack/.venv/lib/python3.13/site-packages/localstack/services/apigateway/next_gen/execute_api/test_invoke.py", line 104, in log_template
    endpoint_response_status_code=endpoint_resp.get("status_code"),
                                  ^^^^^^^^^^^^^^^^^
localstack.aws.api.core.CommonServiceException: exception while calling apigateway.TestInvokeMethod: 'NoneType' object has no attribute 'get'

and this one:

  File "/opt/code/localstack/.venv/lib/python3.13/site-packages/localstack/services/apigateway/next_gen/execute_api/test_invoke.py", line 234, in run_test_invocation
    invocation_context = create_test_invocation_context(test_request, deployment)
  File "/opt/code/localstack/.venv/lib/python3.13/site-packages/localstack/services/apigateway/next_gen/execute_api/test_invoke.py", line 219, in create_test_invocation_context
    resource_method = resource["resourceMethods"][http_method]
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
localstack.aws.api.core.CommonServiceException: exception while calling apigateway.TestInvokeMethod: 'POST'

The first one is because we probably didn't handle failed invocation, and always expected every failed to be present. We need to guard against None-values when calling .get(), and improve it all together. The solution is not bullet proof, because to have perfect logging, we need to store the log as we progress in the invocation to be able to "stop" at the right moment, where the exception happens.

The second one is because we did not handle the ANY values properly, and also did not handle failures when the method would not exist.

Changes

  • add new tests to cover the exceptions raised
  • improve exception handling in the TestInvokeMethod and add some fallbacks
  • sneaked a small fix with the kind of exception raised which was shown in the failing test
  • add better validation of existing methods

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bentsku
fix TestInvokeMethod 500 failures
ed9cd64
@bentsku bentsku added this to the 4.10 milestone Sep 29, 2025
@bentsku bentsku self-assigned this Sep 29, 2025
@bentsku bentsku added aws:apigateway Amazon API Gateway semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Sep 29, 2025
@bentsku bentsku modified the milestones: 4.10, 4.9 Sep 29, 2025
@github-actions

github-actions Bot commented Sep 29, 2025

Copy link
Copy Markdown

LocalStack Community integration with Pro

    2 files      2 suites   17m 1s ⏱️
1 162 tests 1 094 ✅ 68 💤 0 ❌
1 164 runs  1 094 ✅ 70 💤 0 ❌

Results for commit ed9cd64.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 29, 2025

Copy link
Copy Markdown

Test Results - Preflight, Unit

22 281 tests  ±0   20 538 ✅ ±0   15m 44s ⏱️ ±0s
     1 suites ±0    1 743 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit ed9cd64. ± Comparison against base commit 76c3b50.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 29, 2025

Copy link
Copy Markdown

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 22s ⏱️ ±0s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit ed9cd64. ± Comparison against base commit 76c3b50.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 29, 2025

Copy link
Copy Markdown

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   34m 50s ⏱️
1 186 tests 1 119 ✅ 67 💤 0 ❌
1 192 runs  1 119 ✅ 73 💤 0 ❌

Results for commit ed9cd64.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bentsku
bentsku marked this pull request as ready for review September 29, 2025 21:04
@bentsku
bentsku requested a review from cloutierMat as a code owner September 29, 2025 21:04
cloutierMat
cloutierMat approved these changes Sep 30, 2025
View reviewed changes

@cloutierMat cloutierMat left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for jumping on this! 🙏 LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bentsku reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bentsku
bentsku merged commit 13a2c87 into main Sep 30, 2025
@bentsku
bentsku deleted the apigw-fix-test-invoke branch September 30, 2025 08:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@cloutierMat cloutierMat cloutierMat approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@bentsku bentsku

Labels

aws:apigateway Amazon API Gateway docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Milestone

4.9

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bentsku @cloutierMat
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.