- Symptom
- {"message": "Internal server error"} with HTTP 502Execution log: Execution failed due to configuration error: Malformed Lambda proxy responseLambda returns a plain object or a body that is an object
- Cause
- A REST API proxy integration only accepts a response object with statusCode, optional headers, and body as a string. Any other shape, including an object body, becomes a 502.
- Fix
- Return statusCode and a JSON string body from the handler, and add CORS headers there because proxy integrations do not add them.
- Apply
export const handler = async () => ({ statusCode: 200, headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }, body: JSON.stringify({ ok: true }), });- Affected
- REST APIs (v1) with Lambda proxy integration (type AWS_PROXY), whose response shape is fixed; HTTP APIs only when the integration uses payload format version 1.0, since 2.0 infers a response from plain JSON
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders