Skip to content

Preserve Original Error Details #609

@mikelese

Description

@mikelese

Problem

I am building a step function that uses deno as its runtime. To get around deno not being a supported runtime, I've been using this project, per deno's own recommendation.

When running lambdas with the AWS_LWA_ERROR_STATUS_CODES set, the Lambda Web Adapter discards HTTP error response bodies and replaces them with generic Rust-formatted errors.

This breaks branching logic, retry logic, and general error reporting in my Step Function workflow.

Environment

  • AWS Lambda Web Adapter version: 0.9.1
  • Deploying Deno applications in ECR containers
  • Using AWS Step Functions for workflow orchestration

Reproduction Steps

  1. Configure AWS_LWA_ERROR_STATUS_CODES=400-599 in Dockerfile
  2. Deploy a web application that returns HTTP error responses with bodies (e.g., 500 status with {"code":"SERVICE_UNAVAILABLE","detail":"Backend failed"})
  3. Use the Lambda function in an AWS Step Function with error handling logic
  4. Observe that all errors result in the same generic message instead of original content:
{
  "error": {
    "Error": "&alloc::boxed::Box<dyn core::error::Error + core::marker::Send + core::marker::Sync>",
    "Cause": "{\"errorMessage\":\"Request failed with configured error status code: 500\"}"
  }
}

Root Cause

In src/lib.rs lines 394-403, HTTP error responses are converted to status-code-only messages:

if error_codes.contains(&status) {
    return Err(Error::from(format!(
        "Request failed with configured error status code: {}",  // ← Discards body
        status
    )));
}

This loses the original error details (response body, headers) needed for Step Function decision making.

Expected Behavior

The adapter should preserve the complete HTTP error response (status code, body, and headers) when AWS_LWA_ERROR_STATUS_CODES triggers an error.

Impact

Blocks production usage for Step Functions users who require:

  • Error payload inspection for workflow transitions
  • Context-specific retry policies
  • Meaningful error reporting to operators

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions