{"record":{"id":"072a8b226850de7e","repo":"remotion-dev/remotion","slug":"invalid-json-json-stringify-decoded","errorCode":null,"errorMessage":"Invalid JSON: ${JSON.stringify(decoded)}","messagePattern":"Invalid JSON: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/call-lambda-sync.ts","lineNumber":53,"sourceCode":"\n\tif (res.FunctionError) {\n\t\tthrow new Error(\n\t\t\t`Lambda function returned error: ${res.FunctionError} ${res.LogResult}`,\n\t\t);\n\t}\n\n\tif (!res.Payload) {\n\t\tthrow new Error(\n\t\t\t`Lambda function returned no payload (status ${res.StatusCode})`,\n\t\t);\n\t}\n\n\tconst decoded = new TextDecoder('utf-8').decode(res.Payload);\n\n\ttry {\n\t\treturn JSON.parse(decoded) as OrError<ServerlessReturnValues<Provider>[T]>;\n\t} catch {\n\t\tthrow new Error(`Invalid JSON: ${JSON.stringify(decoded)}`);\n\t}\n};\n\nexport const callFunctionSyncImplementation = async <\n\tProvider extends CloudProvider,\n\tT extends ServerlessRoutines,\n>(\n\toptions: CallFunctionOptions<T, Provider>,\n): Promise<ServerlessReturnValues<Provider>[T]> => {\n\tconst res = await callLambdaSyncWithoutRetry<T, Provider>(options);\n\tif (res.type === 'error') {\n\t\tconst err = new Error(res.message);\n\t\terr.stack = res.stack;\n\t\tthrow err;\n\t}\n\n\treturn res;\n};","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/call-lambda-sync.ts#L35-L71","documentation":"Thrown after UTF-8 decoding the sync response payload when JSON.parse fails. Means the function returned a body that is not valid JSON (e.g. an HTML error page, a plain string, or a truncated response). The decoded string is included via JSON.stringify.","triggerScenarios":"Sync Lambda routine whose handler returned non-JSON, or whose response was rewritten/truncated before reaching the client.","commonSituations":"Version mismatch between lambda-client and the deployed function (different protocol), a proxy returning its own HTML error page, partially truncated payload.","solutions":["Redeploy the Lambda function so its version matches the lambda-client version you call with","Inspect the decoded string embedded in the error to see what non-JSON body came back","Ensure no proxy/CDN is rewriting the Lambda response body"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await getCompositionsOnLambda({...});\n} catch (err) {\n  if ((err as Error).message.startsWith('Invalid JSON:')) {\n    // version mismatch — redeploy the function with the current lambda-client\n  }\n  throw err;\n}","preventionTips":["Pin and align @remotion/lambda-client and deployed function versions","Ensure no proxy rewrites the Lambda response body","Log the decoded non-JSON body for diagnosis"],"tags":["aws","lambda","json","version-mismatch"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}