fix: preserve response body when error_status_codes triggers#668
Merged
fix: preserve response body when error_status_codes triggers#668
Conversation
Previously, when AWS_LWA_ERROR_STATUS_CODES matched a response status
code, the adapter discarded the HTTP response body and returned a
generic error message. This broke Step Functions workflows that rely
on error payloads for branching and retry logic.
Now the error includes a JSON object with both the status code and the
original response body:
{"statusCode":502,"body":"Bad Gateway"}
This allows consumers like Step Functions to inspect the original error
details for decision making.
Fixes #609
📊 Benchmark ComparisonBenchmark Details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
AWS_LWA_ERROR_STATUS_CODESmatched a response status code, the adapter discarded the HTTP response body and returned a generic error:{"errorMessage": "Request failed with configured error status code: 500"}This broke Step Functions workflows (and other consumers) that rely on error payloads for branching, retry logic, and error reporting.
Reported in #609.
Fix
The error now includes a JSON object with both the status code and the original response body:
{"statusCode": 502, "body": "Bad Gateway"}For JSON response bodies, the body is properly escaped:
{"statusCode": 500, "body": "{\"code\":\"SERVICE_UNAVAILABLE\",\"detail\":\"Backend failed\"}"}Changes
src/lib.rs: Collect response body before returning error; format as structured JSON withstatusCodeandbodyfieldsCargo.toml: Movehttp-body-utilfrom dev-dependencies to dependencies (needed forBodyExt::collect())tests/integ_tests/main.rs: Update existing test to verify response body is preserved in errorTesting
All 62 tests pass. The existing
test_http_error_status_codestest now also asserts that the response body ("Bad Gateway") is present in the error message.Fixes #609