Skip to content

APIGW: fix OpenAPI import StatusCode string casting #12137

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 4 commits into from
Jan 23, 2025

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Jan 14, 2025

Motivation

We got a report that importing a specific OpenAPI file in API Gateway v1 would result in a type error in OpenTOFU:

deserialization failed, failed to decode response body with invalid JSON, expected StatusCode to be of type string, got json.Number instead

This is because we were not casting as string the status code for the Method status code, and the IntegrationResponse.

When importing an API, we do so by creating the resources "in memory" directly and not via API calls, as this was how on the implementation was. This particular piece of code needs to be reworked fully, but this is out of scope of this PR.

Changes

  • add a test reproducing a similar exception
  • cast imported status codes to string

@bentsku bentsku added aws:apigateway Amazon API Gateway semver: patch Non-breaking changes which can be included in patch releases labels Jan 14, 2025
@bentsku bentsku self-assigned this Jan 14, 2025
@bentsku bentsku requested a review from cloutierMat as a code owner January 14, 2025 14:22
Copy link

github-actions bot commented Jan 14, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 51m 45s ⏱️ -34s
4 005 tests +1  3 688 ✅ +1  317 💤 ±0  0 ❌ ±0 
4 007 runs  +1  3 688 ✅ +1  319 💤 ±0  0 ❌ ±0 

Results for commit 6343abc. ± Comparison against base commit e5e74db.

♻️ This comment has been updated with latest results.

"responseParameters": {
"method.response.header.Access-Control-Allow-Origin": "'*'"
},
"statusCode": "200",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

before the fix, this would have been an int and fail with some typed languages trying to decode the response

@bentsku bentsku force-pushed the fix-apigw-get-resources branch 2 times, most recently from abf0057 to 9198503 Compare January 21, 2025 12:36
@bentsku bentsku requested review from simonrw and pinzon January 22, 2025 00:24
@bentsku bentsku force-pushed the fix-apigw-get-resources branch from 9198503 to 24ef95f Compare January 22, 2025 10:46
Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

Thanks for improving the parity with this change, and yes types and yaml are not good friends!

@bentsku bentsku added this to the 4.1 milestone Jan 22, 2025
@bentsku bentsku force-pushed the fix-apigw-get-resources branch from 24ef95f to 6343abc Compare January 22, 2025 17:39
@bentsku bentsku merged commit d676d6a into master Jan 23, 2025
31 checks passed
@bentsku bentsku deleted the fix-apigw-get-resources branch January 23, 2025 11:04
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