8000 APIGW: fix requestOverride not being present in responseTemplates by bentsku · Pull Request #11799 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

APIGW: fix requestOverride not being present in responseTemplates #11799

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 1 commit into from
Nov 7, 2024

Conversation

bentsku
Copy link
Contributor
@bentsku bentsku commented Nov 6, 2024

Motivation

As reported in our Community Slack, having a similar flow as the one added in this test in a VTL template did not work currently.

The idea is to get some data from the incoming request, maybe transform it and set it in the context.requestOverride.
Then, the response template can access it and transform it/do conditional logic on it.

As we don't want to directly mutate the passed context, we deep copy it before sending it down for rendering (as we don't fully control the rendering logic and what is protected or not).
We then need to attach the requestOverride data back to the context so that it is available in the context in the response template to execute logic on it.

Changes

  • attach back the requestOverride to the context variables
  • add a pretty complex test checking logic to parse b64 encoded data in the path to attach it to requestOverride, then parse the JSON back in the response template and execute logic on it

@bentsku bentsku added aws:apigateway Amazon API Gateway semver: patch Non-breaking changes which can be included in patch releases labels Nov 6, 2024
@bentsku bentsku added this to the 4.0 milestone Nov 6, 2024
@bentsku bentsku self-assigned this Nov 6, 2024
@bentsku bentsku requested a review from cloutierMat as a code owner November 6, 2024 23:17
Copy link
github-actions bot commented Nov 6, 2024

LocalStack Community integration with Pro

  2 files  ±    0    2 suites  ±0   25m 55s ⏱️ - 1h 15m 48s
821 tests  - 2 713  760 ✅  - 2 359  61 💤  - 354  0 ❌ ±0 
823 runs   - 2 713  760 ✅  - 2 359  63 💤  - 354  0 ❌ ±0 

Results for commit 26cda04. ± Comparison against base commit d5cd2dc.

This pull request removes 2714 and adds 1 tests. Note that renamed tests count towards both.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…
tests.aws.services.apigateway.test_apigateway_integrations ‑ test_integration_mock_with_request_overrides_in_response_template
This pull request removes 355 skipped tests and adds 1 skipped test. Note that renamed tests count towards both.
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input4-FAILED]
tests.aws.scenario.mythical_mysfits.test_mythical_misfits.TestMythicalMisfitsScenario ‑ test_deployed_infra_state
tests.aws.scenario.mythical_mysfits.test_mythical_misfits.TestMythicalMisfitsScenario ‑ test_populate_data
tests.aws.scenario.mythical_mysfits.test_mythical_misfits.TestMythicalMisfitsScenario ‑ test_user_clicks_are_stored
tests.aws.services.cloudcontrol.test_cloudcontrol_api.TestCloudControlResourceApi ‑ test_api_exceptions
tests.aws.services.cloudcontrol.test_cloudcontrol_api.TestCloudControlResourceApi ‑ test_create_exceptions
tests.aws.services.cloudcontrol.test_cloudcontrol_api.TestCloudControlResourceApi ‑ test_create_invalid_desiredstate
tests.aws.services.cloudcontrol.test_cloudcontrol_api.TestCloudControlResourceApi ‑ test_double_create_with_client_token
tests.aws.services.cloudcontrol.test_cloudcontrol_api.TestCloudControlResourceApi ‑ test_lifecycle
…
tests.aws.services.apigateway.test_apigateway_integrations ‑ test_integration_mock_with_request_overrides_in_response_template

Copy link
Contributor
@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

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

Interesting use case for the request override! 👀 Thanks for adding such a clear test as well!

@bentsku bentsku merged commit a8338ca into master Nov 7, 2024
39 checks passed
@bentsku bentsku deleted the apigw-vtl-request-overrides branch November 7, 2024 00:16
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: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0