Skip to content

fix(lambda-events): accept non-ASCII header values with http 1.6 - #1200

Open
ranjithguggilla wants to merge 1 commit into
aws:mainfrom
ranjithguggilla:fix/header-values-non-ascii-http-1.6
Open

ranjithguggilla wants to merge 1 commit into
aws:mainfrom
ranjithguggilla:fix/header-values-non-ascii-http-1.6

Conversation

@ranjithguggilla

@ranjithguggilla ranjithguggilla commented Dec 2, 2026 •

Copy link
Copy Markdown

Issue #: none that I could find. Related but different: #1188 (control characters).

Description of changes:

http 1.6.0 changed HeaderValue::from_str / str::parse so they reject non-ASCII. The header deserializers in aws_lambda_events used .parse(), so an API Gateway, ALB, or VPC Lattice event with a UTF-8 header value fails to deserialize. Because the repo has no Cargo.lock, CI on main now fails test_serialize_utf8_headers for the same reason.

This switches those three call sites to HeaderValue::from_bytes, which still accepts bytes above 0x7F and still rejects control characters. Same change for the API Gateway v2 cookie join in lambda-http, where one non-ASCII cookie was dropping the whole Cookie header.

Added coverage for multi-value UTF-8 headers, comma-separated UTF-8 headers (VPC Lattice), non-ASCII cookies, and keeping the control-character rejection.

Checked locally against http 1.6.0: cargo +nightly fmt --all -- --check, cargo clippy --workspace --all-features -- -D warnings, cargo test --all-features for aws_lambda_events (238) and lambda_http (98), and make check-event-features.

By submitting this pull request

  • I confirm that I've ran cargo +nightly fmt.
  • I confirm that I've ran cargo clippy --fix.
  • I confirm that I've made a best effort attempt to update all relevant documentation.
  • I confirm that my contribution is made under the terms of the Apache 2.0 license.

http 1.6.0 changed the string conversions of `HeaderValue` (`from_str`,
`str::parse`) to reject non-ASCII characters. The header deserializers
parsed JSON strings that way, so a request with a UTF-8 header value
failed to deserialize, and `test_serialize_utf8_headers` fails on main
with the current http release.

Build the values with `HeaderValue::from_bytes`, which still accepts
bytes above 0x7F and still rejects control characters. Do the same for
the API Gateway v2 `cookies` list in lambda-http, where a non-ASCII
cookie made the whole Cookie header disappear.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant