{"record":{"id":"567c423d9d4bed62","repo":"remotion-dev/remotion","slug":"could-not-locate-the-composition-id","errorCode":null,"errorMessage":"Could not locate the composition id","messagePattern":"Could not locate the composition id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/composition-source-edits.ts","lineNumber":291,"sourceCode":"\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const item of missingMetadata) {\n\t\t\t\t\t\t\tchangesMade.push({description: `Added ${item.description}`});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst idAttribute = element.openingElement.attributes.find(\n\t\t\t\t\t(attr) =>\n\t\t\t\t\t\tattr.type === 'JSXAttribute' &&\n\t\t\t\t\t\tattr.name.type === 'JSXIdentifier' &&\n\t\t\t\t\t\tattr.name.name === 'id',\n\t\t\t\t);\n\t\t\t\tif (idAttribute?.type !== 'JSXAttribute') {\n\t\t\t\t\tthrow new Error('Could not locate the composition id');\n\t\t\t\t}\n\n\t\t\t\tedits.push(\n\t\t\t\t\tgetJsxStringAttributeValueSourceEdit({\n\t\t\t\t\t\tattribute: idAttribute,\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tnewValue: codeMod.newId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tchangesMade.push({description: 'Replaced composition id'});\n\t\t\t\treturn false;\n\t\t\t},\n\t\t});\n\t}\n\n\tif (changesMade.length === 0) {\n\t\tthrow new Error(\n\t\t\t'Unable to calculate the changes needed for this file. Edit the file manually.',","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/composition-source-edits.ts#L273-L309","documentation":"For rename-composition (and other id-rewriting codemods), after matching the composition the codemod locates the id JSXAttribute to replace its string value. If no id attribute exists on the matched element, it throws this error.","triggerScenarios":"editCompositionInSource with rename-composition where getCompositionId(element) matched the target id (e.g. via an expression form) but the attributes array contains no JSXAttribute named 'id' that is a JSXAttribute with a JSXIdentifier name — i.e. the id is supplied some other way (spread props like {...{id: 'x'}}, dynamic id).","commonSituations":"Compositions whose id comes from a spread attribute, a variable, or a shorthand construct that getCompositionId resolves differently from the attribute search.","solutions":["Give the <Composition> an explicit static id=\"...\" attribute","Remove spread props that supply id and write it inline","Rename the composition manually in the source"],"exampleFix":"// before: <Composition {...compProps} durationInFrames={100} />\n// after:  <Composition id=\"MyComp\" {...compProps} durationInFrames={100} />","handlingStrategy":"validation","validationCode":"const hasStaticId = /<Composition[^>]*\\sid=\"[^\"]+\"/.test(input);\nif (!hasStaticId) throw new Error('Composition must have a static id attribute');","typeGuard":"const hasIdAttribute = (el: any) => el.openingElement?.attributes?.some((a: any) => a.type === 'JSXAttribute' && a.name?.name === 'id');","tryCatchPattern":"try {\n  editCompositionInSource({input, codeMod});\n} catch (e) {\n  if ((e as Error).message.includes('Could not locate the composition id')) {\n    // add an explicit id=\"...\" attribute, then retry\n  }\n}","preventionTips":["Always declare id as a static string attribute on <Composition>","Avoid spreading props that supply id","Don't compute the composition id dynamically in Root"],"tags":["codemod","jsx","composition-id"],"backgroundTag":"entity-not-found","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}