{"record":{"id":"c46c792edba0d90a","repo":"remotion-dev/remotion","slug":"lambda-function-returned-an-error-decoded-result","errorCode":null,"errorMessage":"Lambda function returned an error: {decoded_result['errorMessage']}","messagePattern":"Lambda function returned an error: (.+?)","errorType":"exception","errorClass":"RemotionRenderingOutputError","httpStatus":null,"severity":"error","filePath":"packages/lambda-python/remotion_lambda/remotionclient.py","lineNumber":500,"sourceCode":"            parsed_results = self._parse_stream(result_raw)\n            decoded_result = parsed_results[-1] if parsed_results else {}\n        except ClientError as e:\n            raise e\n        except ParamValidationError as e:\n            raise RemotionInvalidArgumentException(\n                f\"Invalid Lambda invocation parameters: {e}\"\n            ) from e\n        except json.JSONDecodeError as e:\n            raise RemotionException(\n                f\"Failed to decode final Lambda response: {e}. Raw response: {result_raw}\"\n            ) from e\n        except UnicodeDecodeError as e:\n            raise RemotionException(\n                f\"Failed to decode Lambda response payload: {e}\"\n            ) from e\n\n        if 'errorMessage' in decoded_result:\n            raise RemotionRenderingOutputError(\n                f\"Lambda function returned an error: {decoded_result['errorMessage']}\"\n            )\n\n        if 'type' in decoded_result and decoded_result['type'] == 'error':\n            raise RemotionRenderingOutputError(\n                f\"Remotion rendering error: {decoded_result['message']}\"\n            )\n        if 'type' not in decoded_result or decoded_result['type'] != 'success':\n            raise RemotionRenderingOutputError(\n                f\"Unexpected Lambda response format: {result_raw}\"\n            )\n\n        return decoded_result\n\n    def _custom_serializer(self, obj: Any) -> Any: # Added type hints\n        \"\"\"A custom JSON serializer that handles enums and objects.\"\"\"\n        if isinstance(obj, Enum):\n            return obj.value if hasattr(obj, 'value') else obj.name","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-python/remotion_lambda/remotionclient.py#L482-L518","documentation":"Raised after a successful Lambda invocation when the parsed response dict contains an 'errorMessage' key. This is the Lambda runtime's standard shape for an uncaught exception inside the function - the function crashed, not the network or protocol.","triggerScenarios":"The deployed Remotion Lambda function threw an uncaught exception (chromium crash, out of memory, missing codec, bad input). The 'errorMessage' value typically contains the JS stack trace from the function.","commonSituations":"Chromium headless crash due to low memory; FFmpeg missing a codec on the Lambda layer; an error thrown by the user's composition code; incompatible Remotion bundle vs runtime; S3 read failure from inside the function.","solutions":["Read the full 'errorMessage' value (often a JS stack trace) to identify the failing line inside the function.","Increase Lambda memory (Remotion recommends at least 2048MB; more for heavy compositions).","Check CloudWatch Logs for the function for the full error and surrounding context.","Verify the deployed bundle version matches the deployed Lambda layer (chromium/FFmpeg) version."],"exampleFix":"// before - function runs out of memory\naws lambda update-function-configuration --function-name remotion-render-... --memory-size 1024\nclient.render_media(...)\n\n# after\naws lambda update-function-configuration --function-name remotion-render-... --memory-size 4096\nclient.render_media(...)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\\n    result = client.render_media(...)\\nexcept RemotionRenderingOutputError as e:\\n    msg = str(e)  # contains decoded_result['errorMessage']\\n    log.error('Lambda crashed: %s', msg)\\n    # surface to monitoring; do NOT blindly retry without fixing the function\\n    raise","preventionTips":["Provision at least 2048MB (more for heavy compositions) of Lambda memory.","Use a matching Remotion bundle and chromium/FFmpeg layer version.","Read the errorMessage stack trace from CloudWatch before retrying."],"tags":["python","lambda","rendering-error","aws","chromium"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}