remotion-dev/remotion · error · InvalidArgumentException

'composition' is required.

Error message

'composition' is required.

What it means

Thrown by constructInternals when the RenderParams object has an empty composition. The composition id is mandatory — it tells the deployed Remotion Lambda which entry point to render — so the client refuses to send a request without one rather than letting the function fail opaquely. This is the only validation error in the set and is entirely caller-side.

Source

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

        return true;
    }

    /**
     * Normalize payload to ensure valid JSON object is returned
     */
    private function ensureValidPayload(?string $payload): string
    {
        if (is_null($payload) || empty($payload) || $payload === "null") {
            return json_encode(new stdClass());
        }

        return $payload;
    }

    public function constructInternals(RenderParams $render)
    {
        if (empty($render->getComposition())) {
            throw new InvalidArgumentException("'composition' is required.");
        }

        $input = $this->serializeInputProps(
            $render->getData(),
            $this->getRegion(),
            "video-or-audio",
            null
        );

        $render->internal_setSerializedInputProps($input);
        $render->setServeUrl($this->getServeUrl());
        $render->setRegion($this->getRegion());

        return $render->serializeParams();
    }

    public function renderMediaOnLambda(RenderParams $render): RenderMediaOnLambdaResponse
    {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Call $render->setComposition('MyVideo') before invoking constructInternals.
  2. Validate the composition id is non-empty at the boundary where you receive it from user/config input.
  3. Cross-check the id against the list returned by `npx remotion compositions` in your serve bundle.

Example fix

// before
$render = new RenderParams();
$render->setData(['title' => 'Hello']);
$client->constructInternals($render); // throws

// after
$render = new RenderParams();
$render->setComposition('Main');
$render->setData(['title' => 'Hello']);
$client->constructInternals($render);
Defensive patterns

Strategy: validation

Validate before calling

// Validate at the boundary where composition id enters.
$composition = trim((string) $input->get('composition'));
if ($composition === '') {
    throw new InvalidArgumentException('composition is required');
}
$render->setComposition($composition);

Type guard

function hasComposition(RenderParams $r): bool {
    return $r->getComposition() !== '' && $r->getComposition() !== null;
}

Prevention

When it happens

Trigger: Calling constructInternals (or any render method that calls it) on a RenderParams instance where setComposition() was never called or was called with an empty string. ensureValidPayload only normalizes input props; it does not default the composition.

Common situations: Constructing a RenderParams from user input and forgetting to set the composition. Loading a composition id from config that came back empty due to a typo. Reusing a RenderParams across renders and clearing state in between.

Related errors


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