A developer uses API Gateway Lambda proxy integration and returns an application/json response. Some clients report intermittent 502 errors only under high concurrency. Which change most likely fixes the issue?
Answer
Ensure the Lambda returns a valid JSON string in body and sets statusCode correctly; avoid returning non-serializable objects
Explanation
Lambda proxy requires a properly structured response object; invalid JSON or malformed status/body content can surface as 502s. Correct serialization and statusCode handling eliminates those intermittents.
Last reviewed: October 2026
Reviewed by FirstInTest Editorial Team
Related questions
A Lambda writes to DynamoDB using PutItem and sometimes duplicates writes when clients retry after timeouts. The table uses a composite primary key (orderId, eventTime). Which strategy provides end-to-end idempotency without requiring exactly-once execution?
View question →
You deploy a service where API Gateway invokes Lambda using an alias. CloudFormation replaces the function during updates, and some requests intermittently route to the old version. Which configuration most directly prevents this routing inconsistency?
View question →
In the described API flow, which change best reduces cold-start latency for Lambda-integrated API Gateway without increasing idle cost significantly?
View question →
A Step Functions workflow uses an activity worker that sometimes times out due to slow downstream processing. You want automatic recovery with minimal duplicate processing. What is the best tactic?
View question →
You are building a serverless backend that must stream large uploads to S3 while generating metadata via a Lambda trigger. When should you prefer S3 ObjectCreated events over API Gateway/Lambda polling?
View question →
A developer uses a Step Functions workflow that calls two Lambdas in parallel, then writes results to DynamoDB. The workflow occasionally fails due to throttling and inconsistent partial writes. Which approach most reliably preserves correctness and retries safely?
View question →