{"record":{"id":"b5e71eff86f275a3","repo":"remotion-dev/remotion","slug":"could-not-locate-the-update-name-attribute","errorCode":null,"errorMessage":"Could not locate the \"${update.name}\" attribute","messagePattern":"Could not locate the \"(.+?)\" attribute","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/composition-source-edits.ts","lineNumber":205,"sourceCode":"\t\t\t\t\t\t\t\tstart: recastLocToOffset(\n\t\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t\tmetadataAttribute.value.loc.start,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tend: recastLocToOffset(input, metadataAttribute.value.loc.end),\n\t\t\t\t\t\t\t\treplacement: `{${update.value}}`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if (metadataAttribute.loc) {\n\t\t\t\t\t\t\tconst offset = recastLocToOffset(\n\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\tmetadataAttribute.loc.end,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tedits.push({\n\t\t\t\t\t\t\t\tstart: offset,\n\t\t\t\t\t\t\t\tend: offset,\n\t\t\t\t\t\t\t\treplacement: `={${update.value}}`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Could not locate the \"${update.name}\" attribute`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tchangesMade.push({\n\t\t\t\t\t\t\tdescription: `Replaced ${update.description}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tconst missingMetadata = metadata.filter(\n\t\t\t\t\t\t(item) => item.value !== null && !existingMetadata.has(item.name),\n\t\t\t\t\t);\n\t\t\t\t\tif (missingMetadata.length > 0) {\n\t\t\t\t\t\tconst {openingElement} = element;\n\t\t\t\t\t\tif (!openingElement.loc || !openingElement.name.loc) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t'Could not locate the composition opening element',\n\t\t\t\t\t\t\t);","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/composition-source-edits.ts#L187-L223","documentation":"When updating composition metadata, the codemod replaces the value of an existing attribute (fps, durationInFrames, width, height). If the attribute's value node has no loc AND the attribute node itself has no loc, no source range can be targeted for the replacement, so it throws with the attribute name.","triggerScenarios":"Visiting the matching <Composition> where a metadata JSXAttribute (e.g. width) exists but both metadataAttribute.value.loc and metadataAttribute.loc are undefined — typically an attribute node synthesized by a previous AST transformation.","commonSituations":"Files previously rewritten by codemods that built attributes programmatically without preserving recast locations.","solutions":["Re-parse the original source and retry the codemod on a fresh AST","Reformat the file with prettier so attributes exist as plain source text, then re-run","Edit the attribute value manually"],"exampleFix":"// before: <Composition {.../* width built programmatically, no loc */}\n// after: re-run codemod on file containing literal: <Composition ... width={1080} />","handlingStrategy":"try-catch","validationCode":"const attributesLocated = (ast: any) => JSON.stringify(ast).match(/\"loc\":null/) === null;","typeGuard":"const hasLoc = (n: {loc?: unknown} | null | undefined) => !!n && n.loc != null;","tryCatchPattern":"try {\n  editCompositionInSource({input, codeMod});\n} catch (e) {\n  if ((e as Error).message.includes('Could not locate the')) {\n    // reparse original source or edit the attribute manually\n  }\n}","preventionTips":["Write composition metadata attributes (fps, durationInFrames, width, height) as literal JSX attributes","Avoid spread props for metadata on <Composition>","Reformat the file with prettier before running codemods"],"tags":["codemod","jsx","source-locations"],"backgroundTag":"internal-invariant-violation","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"}