Skip to content

fix(event_handler): accept unquoted multipart params and case-insensitive boundary - #8919

Open
Vabs1002 wants to merge 1 commit into
aws-powertools:developfrom
Vabs1002:fix/8909-multipart-header-params
Open

Vabs1002 wants to merge 1 commit into
aws-powertools:developfrom
Vabs1002:fix/8909-multipart-header-params

Conversation

@Vabs1002

Copy link
Copy Markdown

Issue number: closes #8909

Summary

Changes

Both changes are in middlewares/openapi_validation.py.

  • _extract_header_param now accepts an unquoted token value (name=description) as well as a quoted string. RFC 7578 uses the RFC 2183 parameter syntax, where a value can be either. The segment anchoring from fix(event_handler): harden multipart and JSON body validation #8626 is unchanged, so name still doesn't match inside filename.
  • _extract_multipart_boundary matches the boundary parameter name case-insensitively (RFC 2045). The boundary value itself is still taken as is.

No existing tests were changed.

User experience

Before:

  • A part sent as Content-Disposition: form-data; name=description was skipped, so the request returned 422 with every field reported as missing.
  • Content-Type: multipart/form-data; Boundary=XyZ returned 415 missing_boundary.

After: both requests are parsed like their quoted, lowercase equivalents and return 200. Requests that already worked behave the same.

Verification

  • New functional tests, using the public API only:
    • test_multipart_unquoted_content_disposition_params: unquoted name and filename, filename= before name=, mixed quoting.
    • test_multipart_boundary_parameter_name_is_case_insensitive: Boundary= and BOUNDARY=.
  • All 5 new test cases fail on develop and pass with this change.
  • pytest tests/functional/event_handler tests/unit/event_handler: 1301 passed, 1 skipped (the existing "Not implemented yet" AppSync test).
  • ruff format --check, ruff check and mypy pass on the changed files.
  • I also reproduced the issue end to end with an API Gateway REST event built from tests/events/apiGatewayProxyEvent.json: 422 and 415 on develop, 200 with this change.
  • Tested locally on Python 3.12. I didn't validate against a deployed API Gateway. API Gateway passes the Content-Type and body through unchanged, so the parsing is the same.
  • I used a coding agent to help find the bug and draft the tests. I reviewed the change and ran the checks above myself.

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

…tive boundary

Multipart parsing only matched quoted Content-Disposition values, so parts
sent as `name=field` were skipped and reported as missing (422). The
boundary parameter was matched case-sensitively, so `Boundary=` returned
415 missing_boundary.

Accept unquoted token values in Content-Disposition (RFC 7578 uses the
RFC 2183 syntax) and match the boundary parameter name case-insensitively
(RFC 2045). Quoted values behave as before.

closes aws-powertools#8909
@Vabs1002
Vabs1002 requested a review from a team as a code owner November 27, 2026 17:21
@boring-cyborg

boring-cyborg Bot commented Nov 27, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event_handlers size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: multipart parsing rejects unquoted Content-Disposition params and a capitalised Boundary=

1 participant