-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
apigw clean up the invalid json parser #11968
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
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 30m 47s ⏱️ - 1h 19m 4s Results for commit c8b0a0a. ± Comparison against base commit d2d7409. This pull request removes 2815 tests.
♻️ This comment has been updated with latest results. |
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 a lot for cleaning up our... best? code! 😄 I think we still can improve the quote handling of the key, especially to match the statusCode
value, but then we should be good to go! Thanks a lot again 🙏
if key == "statusCode": | ||
statuscode = int(value) |
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.
I think we had the mistake in our current implementation too, but here we directly check against the stateCode
value without regards to single or double quotes it seems (except of the leftover second if
check)
I think we need to still address that 🤔
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.
oh yes! I must have been tired when I wrote made the cleanup! The goal of moving it under the quotes assertions, was to solve this very issue! But it isn't removing the quotes anymore as we originally had 🤦
'{statusCode: 200, " ": " "}', | ||
'{statusCode: 200, "": ""}', |
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.
we could also add a few cases with statusCode
in single and double quotes, and maybe a few invalid with non closing quotes or something similar?
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.
Good thinking! that is indeed the most important objective 🤣
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.
LGTM! Just a minor simplification, but this is already much cleaner than before 🙏 Thanks a lot for addressing the comments and adding test cases! Really, this is such a weird case...
key, value = [el.strip() for el in key_value] | ||
key = convert_null_value(key) | ||
value = convert_null_value(value) |
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.
nit: could probably be simplified with:
key, value = [el.strip() for el in key_value] | |
key = convert_null_value(key) | |
value = convert_null_value(value) | |
key, value = [convert_null_value(el.strip()) for el in key_value] |
I think we could even put the strip()
call inside convert_null_value
.
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.
Oops, missed it but we could probably add type hints for convert_null_value(value: str) -> str:
Motivation
In an attempt to move fast to fix the issue, with @bentsku. we created #11967.
The naming was done hastily and we will attempt to clean it up a little in this pr.
Changes