{"record":{"id":"87de0c56ecb81ec5","repo":"remotion-dev/remotion","slug":"invalid-lambda-invocation-parameters-e","errorCode":null,"errorMessage":"Invalid Lambda invocation parameters: {e}","messagePattern":"Invalid Lambda invocation parameters: (.+?)","errorType":"exception","errorClass":"RemotionInvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/lambda-python/remotion_lambda/remotionclient.py","lineNumber":487,"sourceCode":"\n    def _invoke_lambda(self, function_name: str, payload: str) -> Dict[str, Any]: # Added type hints\n        \"\"\"Invokes the Remotion Lambda function and parses its response.\"\"\"\n        client = self._create_lambda_client()\n        result_raw: Optional[str] = None # Renamed to avoid confusion with `decoded_result`\n        decoded_result: Dict[str, Any] = {}\n\n        try:\n            # boto3.client('lambda').invoke returns a dictionary.\n            # 'Payload' is a StreamingBody object.\n            response: Dict[str, Any] = client.invoke(FunctionName=function_name, Payload=payload)\n            streaming_body: StreamingBody = response['Payload']\n            result_raw = streaming_body.read().decode('utf-8')\n            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(","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-python/remotion_lambda/remotionclient.py#L469-L505","documentation":"Raised when boto3 rejects the parameters to client.invoke() with a ParamValidationError (before the call). This means FunctionName or Payload has an invalid type/shape - not an AWS service error. ClientError (network/auth/service) is re-raised separately.","triggerScenarios":"Calling _invoke_lambda with a non-string function_name, an empty function name, a Payload that is not bytes/str/file-like, or an internal Lambda client that was constructed with bad parameters.","commonSituations":"function_name resolved to None because the constructor validation was bypassed; payload pre-serialization bug producing None; mocking the Lambda client with broken stubs; integration tests passing wrong types.","solutions":["Inspect __cause__ for the exact ParamValidationError report.","Confirm function_name is a non-empty string matching a deployed Lambda.","Ensure the payload passed to render APIs serializes to a non-empty JSON string.","Recreate the client with valid region/Session so the internal Lambda client is correctly configured."],"exampleFix":"// before\nclient = RemotionClient(region='us-east-1', serve_url=..., function_name='')\nclient.render_media(...)\n\n# after\nclient = RemotionClient(\n    region='us-east-1',\n    serve_url=serve_url,\n    function_name='remotion-render-remotionlambda-...-us-east-1',\n)\nclient.render_media(...)","handlingStrategy":"validation","validationCode":"def preflight_invoke(function_name: str, payload: str) -> None:\n    if not (isinstance(function_name, str) and function_name.strip()):\n        raise ValueError(f'invalid function_name: {function_name!r}')\n    if not isinstance(payload, (str, bytes)):\n        raise ValueError(f'invalid payload type: {type(payload).__name__}')","typeGuard":"def is_invokable(function_name, payload) -> bool:\\n    return (isinstance(function_name, str) and bool(function_name.strip())\\n            and isinstance(payload, (str, bytes)))","tryCatchPattern":"try:\\n    client.render_media(...)\\nexcept RemotionInvalidArgumentException as e:\\n    log.error('invoke param error: %s', e.__cause__)\\n    raise","preventionTips":["Always pass a non-empty function_name from a known deployment.","Use a valid boto3 Session so the internal Lambda client is correctly configured.","Do not bypass constructor validation that guards function_name."],"tags":["python","lambda","validation","aws-sdk","invocation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}