Skip to content

fix(event_handler): convert null body to empty string in ALBResolver to avoid HTTP 502 #4683

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 5 commits into from
Jul 3, 2024

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented Jul 3, 2024

Issue number: #4671

Summary

Auto convert None body responses to empty strings when a Response object is used. By default, ALB raises a HTTP 502 if body is null.

This differs from other resolvers (API GW, Lattice, Function URL).

Docs. To prevent another confusion, this PR updates the doc to move a auto-serialization banner into its own sub-section to explain why a dict in the route function will always end up inside body key.

Changes

Please provide a summary of what's being changed

  • Convert None response body to empty string ""
  • Docs: reword Auto-serialization piece
  • Double check how ALB treats json.dumps(None) vs "" in the body
    • null (json NONE) is treated as 4 bytes content-length
    • "" is honoured and sends no content-length
  • Double check whether the lack of content-type also impacts ALB behaviour if a Response object w/o is returned
  • @leandrodamascena agreed to do E2E to be triple sure so I can go on PTO on time :D

User experience

Please share what the user experience looks like before and after this change

image

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@heitorlessa heitorlessa requested a review from a team July 3, 2024 12:51
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 3, 2024
@github-actions github-actions bot added the bug Something isn't working label Jul 3, 2024
Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.46%. Comparing base (e14e768) to head (6798e05).
Report is 696 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4683      +/-   ##
===========================================
+ Coverage    96.38%   96.46%   +0.07%     
===========================================
  Files          214      223       +9     
  Lines        10030    10735     +705     
  Branches      1846     1998     +152     
===========================================
+ Hits          9667    10355     +688     
- Misses         259      268       +9     
- Partials       104      112       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@heitorlessa
Copy link
Contributor Author

heitorlessa commented Jul 3, 2024

NOTE

  • Reword the Auto-serialization banner to explain more succinctly that whatever response from a route function will go inside the body return (if dict -> JSON)

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jul 3, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jul 3, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jul 3, 2024
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 3, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jul 3, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jul 3, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jul 3, 2024
@heitorlessa
Copy link
Contributor Author

@sthulb we're gonna need your approval to get this ready as a pre-release tomorrow, once @leandrodamascena adds E2E test for this tricky ALB thing.

On my way to PTO <3

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jul 3, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jul 3, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jul 3, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jul 3, 2024
@leandrodamascena
Copy link
Contributor

e2e is green!
image

@sthulb sthulb merged commit 7503cf4 into aws-powertools:develop Jul 3, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants