{"record":{"id":"2f9cfcdafd4da1fe","repo":"remotion-dev/remotion","slug":"unexpected-lambda-response-format-result-raw","errorCode":null,"errorMessage":"Unexpected Lambda response format: {result_raw}","messagePattern":"Unexpected Lambda response format: (.+?)","errorType":"exception","errorClass":"RemotionRenderingOutputError","httpStatus":null,"severity":"error","filePath":"packages/lambda-python/remotion_lambda/remotionclient.py","lineNumber":509,"sourceCode":"            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\n        # Check if it's a dataclass instance before calling asdict\n        # This often works better with mypy than just a try-except.\n        if hasattr(obj, '__dataclass_fields__'):\n            return asdict(obj)\n        if hasattr(obj, '__dict__'):\n            return obj.__dict__\n        if hasattr(obj, '__iter__') and not isinstance(obj, (str, bytes, bytearray)):\n            return list(obj)\n","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-python/remotion_lambda/remotionclient.py#L491-L527","documentation":"Raised when the parsed Lambda response dict does NOT contain type === 'success' (and is not an errorMessage or type='error'). This is the catch-all for an unexpected response shape - the function returned something the client cannot interpret as success, controlled error, or runtime crash.","triggerScenarios":"Lambda returns a partial/empty dict, a chunk from a streaming progress event that was selected as the terminal result, or a response from an unrelated Lambda deployed to the same name. The raw response text is included for diagnosis.","commonSituations":"Version mismatch between the Python client and the deployed Remotion Lambda function; calling a non-Remotion Lambda by accident; selecting a progress chunk instead of the final chunk; truncated response leaving an empty dict.","solutions":["Inspect the raw response text in the error message to understand what the function actually returned.","Verify the deployed Lambda function IS a Remotion render function and its version matches the Python client.","Confirm the function name in the client points to the right deployed function.","Re-deploy the function with `remotion lambda functions deploy` and update the client version to match."],"exampleFix":"// before - calling a non-Remotion Lambda\nclient = RemotionClient(region=..., serve_url=..., function_name='my-other-function')\nclient.render_media(...)\n\n# after\nclient = RemotionClient(\n    region=...,\n    serve_url=serve_url,\n    function_name='remotion-render-remotionlambda-...-us-east-1',\n)\nclient.render_media(...)","handlingStrategy":"try-catch","validationCode":"def assert_remotion_function(session, function_name: str) -> None:\n    lam = session.client('lambda')\n    tags = lam.list_tags(Resource=function_name).get('Tags', {})\n    if tags.get('remotion:version') is None:\n        raise ValueError(f'{function_name} does not look like a Remotion Lambda')","typeGuard":null,"tryCatchPattern":"try:\\n    result = client.render_media(...)\\nexcept RemotionRenderingOutputError as e:\\n    raw = str(e)  # contains raw response text\\n    log.error('Unexpected Lambda response format. raw=%s', raw)\\n    raise","preventionTips":["Use a Remotion-deployed Lambda function (look for the remotion:version tag).","Keep the Python client and Lambda function on matching Remotion versions.","Verify the function name in the client matches a deployed Remotion function."],"tags":["python","lambda","response-format","version-mismatch","aws"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}