8000 Fix bug: Support list header value on Step Functions ApiGateway:Invoke integration by ShahadIshraq · Pull Request #11681 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

ShahadIshraq
Copy link
Contributor

Motivation

Fix Issue:11628 and show off

Changes

  • Cast list type header values to string before using for SFN - ApiGW integration
  • Add parity test for these header value types

Testing

  • Run the tests
  • Follow the Steps To Reproduce mentioned on this issue

Copy link
Collaborator
@localstack-bot localstack-bot left a 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.

@localstack-bot
Copy link
Collaborator
localstack-bot commented Oct 12, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ShahadIshraq
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

localstack-bot added a commit that referenced this pull request Oct 12, 2024
@thrau thrau added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Oct 12, 2024
@ShahadIshraq ShahadIshraq force-pushed the i-11628 branch 3 times, most recently from b8bddba to 135c044 Compare October 20, 2024 11:02
@ShahadIshraq ShahadIshraq marked this pull request as ready for review October 20, 2024 11:25
Copy link
Contributor
@MEPalma MEPalma left a 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):
Copy link
Contributor

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):
Copy link
Contributor

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))
Copy link
Contributor

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().

@ShahadIshraq ShahadIshraq force-pushed the i-11628 branch 2 times, most recently from 07aa296 to 54148cd Compare October 21, 2024 17:22
@ShahadIshraq ShahadIshraq requested a review from MEPalma October 21, 2024 17:24

value = headers.get(key)
if isinstance(value, list):
headers[key] = ",".join(value)
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor
@MEPalma MEPalma left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member
@joe4dev joe4dev left a 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) 🚀

@joe4dev joe4dev changed the title Fix bug: bug: support list header value on Step Functions ApiGateway:Invoke integration Fix bug: Support list header value on Step Functions ApiGateway:Invoke integration Oct 29, 2024
@joe4dev joe4dev merged commit 0662122 into localstack:master Oct 29, 2024
34 checks passed
@ShahadIshraq ShahadIshraq deleted the i-11628 branch October 30, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Step Functions ApiGateway:Invoke integration not handling headers as expected.
5 participants
0