Skip to content

fix APIGW import RestAPI version type mismatch#7787

Merged
thrau merged 2 commits intomasterfrom
fix-apigw-import-version-type
Mar 12, 2023
Merged

fix APIGW import RestAPI version type mismatch#7787
thrau merged 2 commits intomasterfrom
fix-apigw-import-version-type

Conversation

@bentsku
Copy link
Contributor

@bentsku bentsku commented Mar 2, 2023

A user reported an issue in the community slack channel that they could not use a Terraform module creating a RestAPI with API Gateway after 1.4.0.

Terraform was creating then updating the API, we would send a 200 status code but it would keep going (it felt like we were returning something unexpected or wrong).

After running the user sampler and re-using the data sent by Terraform to create a snapshot AWS validated test, it seemed the version type we returned was an int when AWS returns a str. After fixing that, the user sample is running.

The snapshot test shows the lack of parity while importing an API, but some of it might be because of how we return the data, and should be fix in our parity effort. Anyway, it's a good indicator on where to focus some effort.

@bentsku bentsku requested a review from calvernaz as a code owner March 2, 2023 20:06
@bentsku bentsku self-assigned this Mar 2, 2023
@bentsku bentsku temporarily deployed to localstack-ext-tests March 2, 2023 20:06 — with GitHub Actions Inactive
@bentsku bentsku added the aws:apigateway Amazon API Gateway label Mar 2, 2023
@github-actions
Copy link

github-actions bot commented Mar 2, 2023

LocalStack integration with Pro

       3 files  ±0         3 suites  ±0   1h 34m 41s ⏱️ + 2m 6s
1 789 tests +1  1 407 ✔️ +2  382 💤  - 1  0 ±0 
2 515 runs  +1  1 781 ✔️ +2  734 💤  - 1  0 ±0 

Results for commit 152ce0b. ± Comparison against base commit 4914f48.

♻️ This comment has been updated with latest results.

@coveralls
Copy link

coveralls commented Mar 2, 2023

Coverage Status

Coverage: 85.083% (+0.03%) from 85.056% when pulling 152ce0b on fix-apigw-import-version-type into 4914f48 on master.

@bentsku bentsku force-pushed the fix-apigw-import-version-type branch from dee68dd to 6d2dea0 Compare March 4, 2023 13:21
@bentsku bentsku temporarily deployed to localstack-ext-tests March 4, 2023 13:21 — with GitHub Actions Inactive
Copy link
Contributor

@calvernaz calvernaz left a comment

Choose a reason for hiding this comment

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

LGTM overall 🚀 . Couple of comments regarding the spec and the field version of the info object.

# 2. validate the document type, "swagger" or "openapi"

rest_api.version = resolved_schema.get("info", {}).get("version")
rest_api.version = str(resolved_schema.get("info", {}).get("version", ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

the info object is required and field title and version the required fields. Translating that to code, I'd prefer not to have a default value that is not valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I didn't dare to change the logic here without having proper testing in place. Should I just leave None instead? Could it create issue down the line with unexpected exception? I suppose I'll just an AWS exception instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea absolutely, I don't think it's a big deal. Something to follow up on, there are a couple of libraries to validate swagger 2 vs 3, but we need to create a proper separation.

},
"info": {
"title": "local-api",
"version": 1
Copy link
Contributor

Choose a reason for hiding this comment

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

"version" should be a string by the spec.

Copy link
Contributor Author

@bentsku bentsku Mar 6, 2023

Choose a reason for hiding this comment

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

Right, yes. So this was an issue from the sample in the first place. However, AWS accepts this, and it allows us to test that we properly cast it to str, should I leave it this way? Otherwise this fix would not be properly tested.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, AWS is probably being lenient - the export operation should also reflect that then. 👍

@bentsku bentsku temporarily deployed to localstack-ext-tests March 8, 2023 13:49 — with GitHub Actions Inactive
@bentsku bentsku temporarily deployed to localstack-ext-tests March 8, 2023 18:00 — with GitHub Actions Inactive
@bentsku bentsku force-pushed the fix-apigw-import-version-type branch from 7ccf743 to 9a4b23e Compare March 9, 2023 17:12
@bentsku bentsku temporarily deployed to localstack-ext-tests March 9, 2023 17:12 — with GitHub Actions Inactive
@bentsku bentsku force-pushed the fix-apigw-import-version-type branch from 9a4b23e to 152ce0b Compare March 10, 2023 09:10
@bentsku bentsku temporarily deployed to localstack-ext-tests March 10, 2023 09:10 — with GitHub Actions Inactive
@thrau thrau merged commit f4d39cf into master Mar 12, 2023
@thrau thrau deleted the fix-apigw-import-version-type branch March 12, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws:apigateway Amazon API Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants