Skip to content

Apigw/add support for response override in request #12628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 16, 2025

Conversation

cloutierMat
Copy link
Contributor

@cloutierMat cloutierMat commented May 16, 2025

Motivation

This is a partial solve for #12621.

This pr will allow to use responseOverride in a request template and have it's value passed to the context of the response template and possibly affecting the response.

There are 2 issues described by the user. I will work on the VTL template update in a follow up.

Changes

  • Move responsibility of creating the overrides context variable to the parser. Those values are accessible in the context and that will prevent needing to check for their existence everywhere in the code
  • Pass the full return of the context variables from the request mapping to properly update the context that is passed down
  • Added validated test to confirm the behavior

Copy link

github-actions bot commented May 16, 2025

LocalStack Community integration with Pro

    2 files      2 suites   19m 8s ⏱️
1 125 tests 1 060 ✅ 65 💤 0 ❌
1 127 runs  1 060 ✅ 67 💤 0 ❌

Results for commit 38d05a2.

♻️ This comment has been updated with latest results.

@cloutierMat cloutierMat added aws:apigateway Amazon API Gateway semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases labels May 16, 2025
@cloutierMat cloutierMat added this to the 4.5 milestone May 16, 2025
@@ -159,6 +159,7 @@ def create_test_invocation_context(
requestOverride=ContextVarsRequestOverride(header={}, path={}, querystring={}),
responseOverride=ContextVarsResponseOverride(header={}, status=0),
)
invocation_context.trace_id = parse_handler.populate_trace_id({})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 ??

Copy link
Contributor

Choose a reason for hiding this comment

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

it had been deleted in the previous commit, I've just added it back 😄 bb5dbe1

@bentsku bentsku marked this pull request as ready for review May 16, 2025 16:08
@bentsku bentsku self-requested a review as a code owner May 16, 2025 16:08
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

LGTM! This looks good, quite a really weird case by AWS 👀

It's also funny that we can add user-defined fields to the responseOverride, acting like a context stash for user-defined values...

That must have been a fun one 😄 thanks for added parity and jumping on this! 🚀

@@ -159,6 +159,7 @@ def create_test_invocation_context(
requestOverride=ContextVarsRequestOverride(header={}, path={}, querystring={}),
responseOverride=ContextVarsResponseOverride(header={}, status=0),
)
invocation_context.trace_id = parse_handler.populate_trace_id({})
Copy link
Contributor

Choose a reason for hiding this comment

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

it had been deleted in the previous commit, I've just added it back 😄 bb5dbe1

@bentsku bentsku merged commit 5f9ae76 into master May 16, 2025
32 checks passed
@bentsku bentsku deleted the apigw/add-support-for-response-override-in-request branch May 16, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:apigateway Amazon API Gateway semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants