{"record":{"id":"b25341eabc57b306","repo":"remotion-dev/remotion","slug":"failed-to-invoke-lambda-function","errorCode":null,"errorMessage":"Failed to invoke Lambda function","messagePattern":"Failed to invoke Lambda function","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"packages/lambda-php/src/PHPClient.php","lineNumber":306,"sourceCode":"    }\n\n    public function getRenderProgress(string $renderId, string $bucketName, string $logLevel = \"info\", $forcePathStyle = false): GetRenderProgressResponse\n    {\n        $payload = $this->makeRenderProgressPayload($renderId, $bucketName, $logLevel, $forcePathStyle);\n        $result = $this->invokeLambdaFunction($payload);\n        return $this->handleLambdaResponseProgress($result);\n    }\n\n    private function invokeLambdaFunction(string $payload)\n    {\n        $result = $this->client->invoke([\n            'InvocationType' => 'RequestResponse',\n            'FunctionName' => $this->getFunctionName(),\n            'Payload' => $payload,\n        ]);\n\n        if ($result['StatusCode'] !== 200) {\n            throw new Exception(\"Failed to invoke Lambda function\");\n        }\n\n        return $result['Payload']->getContents();\n    }\n\n    private function handleLambdaResponseRender(string $response): RenderMediaOnLambdaResponse\n    {\n        $response = json_decode($response, true);\n\n        // AWS response\n        if (isset($response->errorMessage)) {\n            throw new Exception($response->errorMessage);\n        }\n\n        $classResponse = new RenderMediaOnLambdaResponse();\n\n        // Remotion response\n        if ($response['type'] === 'error') {","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-php/src/PHPClient.php#L288-L324","documentation":"Thrown by invokeLambdaFunction when the Lambda Invoke response's StatusCode is not 200. Note this check is coarse: a 200 with a FunctionError or error payload is handled separately downstream (1197/1199). A non-200 here means the request never reached a successful invocation — function not found, throttled, or service error. The message is static and does not include the body or error code, which makes diagnosis harder.","triggerScenarios":"$this->client->invoke returns a result whose StatusCode is 202 (sync invocation accepted but not 200 in some configurations), 4xx (AccessDenied, ResourceNotFound), 429 (TooManyRequests), or 5xx (AWS service error).","commonSituations":"Function name misconfigured. Caller role lacks lambda:InvokeFunction. AWS throttling under burst. Service-side 5xx during a regional event.","solutions":["Check $result['StatusCode'] and log the full $result (including FunctionError and Payload) — the static message hides the cause.","Verify getFunctionName() returns the deployed function name in the correct region (`aws lambda get-function`).","Grant lambda:InvokeFunction to the caller's IAM role.","For 429/5xx, add exponential backoff around the invoke call.","Improve the library to include $result['FunctionError'] / Payload in the exception message."],"exampleFix":"// before\nif ($result['StatusCode'] !== 200) {\n    throw new Exception(\"Failed to invoke Lambda function\");\n}\n\n// after - include the status and function error so the cause is diagnosable\nif ($result['StatusCode'] !== 200) {\n    $fnError = $result['FunctionError'] ?? 'none';\n    $body = $result['Payload']->getContents();\n    throw new Exception(sprintf(\n        \"Failed to invoke Lambda function %s (status %d, functionError %s): %s\",\n        $this->getFunctionName(),\n        $result['StatusCode'],\n        $fnError,\n        $body\n    ));\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $body = $this->invokeLambdaFunction($payload);\n} catch (Exception $e) {\n    // The static message hides the cause; log $result and FunctionError,\n    // retry only on transient (429/5xx) conditions.\n    throw $e;\n}","preventionTips":["Patch the client to include StatusCode, FunctionError, and Payload in the exception.","Verify getFunctionName() resolves to a deployed function in the right region.","Grant lambda:InvokeFunction to the caller role and add backoff for throttling."],"tags":["aws","lambda","invocation","iam","php","lambda-php"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}