{"record":{"id":"44f993cb4e3ce830","repo":"remotion-dev/remotion","slug":"composition-is-required","errorCode":null,"errorMessage":"'composition' is required.","messagePattern":"'composition' is required\\.","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/lambda-php/src/PHPClient.php","lineNumber":252,"sourceCode":"        return true;\n    }\n\n    /**\n     * Normalize payload to ensure valid JSON object is returned\n     */\n    private function ensureValidPayload(?string $payload): string\n    {\n        if (is_null($payload) || empty($payload) || $payload === \"null\") {\n            return json_encode(new stdClass());\n        }\n\n        return $payload;\n    }\n\n    public function constructInternals(RenderParams $render)\n    {\n        if (empty($render->getComposition())) {\n            throw new InvalidArgumentException(\"'composition' is required.\");\n        }\n\n        $input = $this->serializeInputProps(\n            $render->getData(),\n            $this->getRegion(),\n            \"video-or-audio\",\n            null\n        );\n\n        $render->internal_setSerializedInputProps($input);\n        $render->setServeUrl($this->getServeUrl());\n        $render->setRegion($this->getRegion());\n\n        return $render->serializeParams();\n    }\n\n    public function renderMediaOnLambda(RenderParams $render): RenderMediaOnLambdaResponse\n    {","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-php/src/PHPClient.php#L234-L270","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Call $render->setComposition('MyVideo') before invoking constructInternals.","Validate the composition id is non-empty at the boundary where you receive it from user/config input.","Cross-check the id against the list returned by `npx remotion compositions` in your serve bundle."],"exampleFix":"// before\n$render = new RenderParams();\n$render->setData(['title' => 'Hello']);\n$client->constructInternals($render); // throws\n\n// after\n$render = new RenderParams();\n$render->setComposition('Main');\n$render->setData(['title' => 'Hello']);\n$client->constructInternals($render);","handlingStrategy":"validation","validationCode":"// Validate at the boundary where composition id enters.\n$composition = trim((string) $input->get('composition'));\nif ($composition === '') {\n    throw new InvalidArgumentException('composition is required');\n}\n$render->setComposition($composition);","typeGuard":"function hasComposition(RenderParams $r): bool {\n    return $r->getComposition() !== '' && $r->getComposition() !== null;\n}","tryCatchPattern":null,"preventionTips":["Always call setComposition with a known id from `npx remotion compositions`.","Validate the composition id at the request boundary before constructing RenderParams.","Add a unit test that constructInternals throws cleanly for an unset composition."],"tags":["validation","composition","input","php","lambda-php"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}