-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix bug: Support list header value on Step Functions ApiGateway:Invoke integration #11681
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
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.
Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
b8bddba
to
135c044
Compare
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.
Thank you for looking into this issue, I left a couple of minor comments about the string encoding process
@@ -174,6 +174,10 @@ def _headers_of(parameters: TaskParameters) -> Optional[dict]: | |||
for forbidden_prefix in StateTaskServiceApiGateway._FORBIDDEN_HTTP_HEADERS_PREFIX: | |||
if key.startswith(forbidden_prefix): | |||
raise ValueError(f"The 'Headers' field contains unsupported values: {key}") | |||
|
|||
if isinstance(headers.get(key), list): |
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 can probably access the value for key in headers just once here.
@@ -174,6 +174,10 @@ def _headers_of(parameters: TaskParameters) -> Optional[dict]: | |||
for forbidden_prefix in StateTaskServiceApiGateway._FORBIDDEN_HTTP_HEADERS_PREFIX: | |||
if key.startswith(forbidden_prefix): | |||
raise ValueError(f"The 'Headers' field contains unsupported values: {key}") | |||
|
|||
if isinstance(headers.get(key), list): |
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.
Yes, it seems like checking for 1D lists is sufficient in this case, as headers tend to be string or list of strings
@@ -174,6 +174,10 @@ def _headers_of(parameters: TaskParameters) -> Optional[dict]: | |||
for forbidden_prefix in StateTaskServiceApiGateway._FORBIDDEN_HTTP_HEADERS_PREFIX: | |||
if key.startswith(forbidden_prefix): | |||
raise ValueError(f"The 'Headers' field contains unsupported values: {key}") | |||
|
|||
if isinstance(headers.get(key), list): | |||
headers[key] = str(headers.get(key)) |
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 consider making the encoding slightly more deliberate here (comma separated string literals), perhaps using a json encoder or ','.join().
07aa296
to
54148cd
Compare
|
||
value = headers.get(key) | ||
if isinstance(value, list): | ||
headers[key] = ",".join(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.
Thanks for applying the changes! We can probably wrap this string body between brackets ("h1,h2" -> "[h1,h2]"). It's interesting how the test cases did not highlight this formatting change.
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.
That seems to be breaking other tests 😅
Will check if those can be fixed
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.
Thank you!
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 (after fixing the tiny syntax error) 🚀
Motivation
Fix Issue:11628 and show off
Changes
Testing
Steps To Reproduce
mentioned on this issue