Skip to content

fix(lambda-http): handle fallible response body errors - #1169

Open
IamPritamAcharya wants to merge 1 commit into
aws:mainfrom
IamPritamAcharya:fix/lambda-http-fallible-body-error
Open

fix(lambda-http): handle fallible response body errors#1169
IamPritamAcharya wants to merge 1 commit into
aws:mainfrom
IamPritamAcharya:fix/lambda-http-fallible-body-error

Conversation

@IamPritamAcharya

Copy link
Copy Markdown

📬 Issue #, if available:

Closes #1165

✍️ Description of changes:

lambda_http accepts fallible HttpBody response bodies, but its buffered text
and binary conversion paths called expect() after body.collect().await.
Normal body errors therefore caused an internal panic.

This change:

  • handles collection errors in both text and binary conversion paths;
  • propagates failures from run, run_concurrent, runtime, and
    runtime_concurrent to lambda_runtime as invocation diagnostics;
  • preserves the body error's concrete type and debug message in the diagnostic;
  • returns a deterministic, header-free HTTP 500 with an empty body when
    IntoResponse is used directly;
  • uses the same HTTP 500 fallback for the existing public Adapter, which must
    preserve its handler error type;
  • keeps the public IntoResponse, ResponseFuture, Adapter, and
    TransformResponse signatures unchanged;
  • preserves successful content-type, content-encoding, text, and binary
    conversion behavior;
  • does not modify the separate response-streaming path discussed in [lambda_runtime] early client closure of a streaming response panics when using cargo lambda watch #1051.

Regression tests use a StreamBody that emits partial data and then returns an
UnexpectedEof. Both text and binary paths are covered, along with propagation
through the standard runtime adapter.

Validation performed:

  • cargo +nightly fmt --all -- --check
  • cargo +1.84.0 test --all-features --verbose --package lambda_http
  • cargo check --workspace --all-features
  • cargo test -p lambda_http --all-features
  • cargo test --workspace --all-features --exclude lambda-integration-tests
  • cargo clippy --workspace --all-features -- -D warnings
  • RUSTDOCFLAGS='--cfg docsrs -Dwarnings' cargo +nightly doc --workspace --no-deps --document-private-items --all-features
  • git diff --check

The deployment integration test requires an externally configured
TEST_ENDPOINT and was therefore not run successfully locally.

🔏 By submitting this pull request

  • I confirm that I've ran cargo +nightly fmt.
  • I ran Clippy with the repository CI flags; no automatic fixes were required.
  • 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.

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.

[lambda_http] Fallible response body panics during buffered conversion instead of propagating the body error

1 participant