remotion-dev/remotion · error · Exception

$response->errorMessage

Error message

$response->errorMessage

What it means

Thrown by handleLambdaResponseRender when the decoded Lambda response is detected as an AWS error envelope and its errorMessage is re-thrown. NOTE: there is a latent bug — json_decode is called with `true` (associative array), so `$response` is an array, but the code uses object syntax `$response->errorMessage`. With an associative array, `isset($response->errorMessage)` is false, so this branch effectively never fires for a normal array-shaped error envelope; the dynamic message is whatever the Lambda function returned as errorMessage.

Source

Thrown at packages/lambda-php/src/PHPClient.php:318

            'InvocationType' => 'RequestResponse',
            'FunctionName' => $this->getFunctionName(),
            'Payload' => $payload,
        ]);

        if ($result['StatusCode'] !== 200) {
            throw new Exception("Failed to invoke Lambda function");
        }

        return $result['Payload']->getContents();
    }

    private function handleLambdaResponseRender(string $response): RenderMediaOnLambdaResponse
    {
        $response = json_decode($response, true);

        // AWS response
        if (isset($response->errorMessage)) {
            throw new Exception($response->errorMessage);
        }

        $classResponse = new RenderMediaOnLambdaResponse();

        // Remotion response
        if ($response['type'] === 'error') {
            throw new Exception($response['message']);
        }

        $classResponse->type = $response['type'];
        $classResponse->renderId = $response['renderId'];
        $classResponse->bucketName = $response['bucketName'];

        return $classResponse;
    }

    private function handleLambdaResponseProgress(string $response): GetRenderProgressResponse
    {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Log the raw response payload to capture the full error envelope (errorType + stackTrace), not just errorMessage.
  2. Reproduce locally against the same serve URL and composition to find the runtime cause.
  3. Align the PHP client version with the deployed Remotion Lambda function version.
  4. If you maintain this client, fix the decode-mode bug so the envelope is read consistently (see exampleFix).

Example fix

// before
$response = json_decode($response, true);
if (isset($response->errorMessage)) { // never true for assoc array
    throw new Exception($response->errorMessage);
}

// after - decode as object (or use array syntax consistently)
$response = json_decode($response);
if (isset($response->errorMessage)) {
    throw new Exception($response->errorMessage);
}
Defensive patterns

Strategy: try-catch

Try / catch

// Until the decode-mode bug is fixed, guard defensively.
$body = json_decode($raw, true);
if (is_array($body) && isset($body['errorMessage'])) {
    throw new RuntimeException('Lambda error envelope: ' . $body['errorMessage']);
}
if (is_object($body) && isset($body->errorMessage)) {
    throw new RuntimeException('Lambda error envelope: ' . $body->errorMessage);
}

Prevention

When it happens

Trigger: The Lambda function returns a payload shaped like `{"errorMessage":"...","errorType":"...","stackTrace":[...]}` (the AWS error envelope for an unhandled exception). To trigger this exact branch the value would need to be decoded as an object, which only happens if json_decode's second arg is removed.

Common situations: The deployed Remotion function threw an unhandled exception (out-of-memory, runtime crash, bad input that escaped the typed error path). When the branch does fire, the message reflects the function's exception message verbatim.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/31fb1a0dcf785a5f. Report an issue: GitHub.