{"record":{"id":"fbb0d72cb27a4329","repo":"remotion-dev/remotion","slug":"could-not-locate-the-folder-name","errorCode":null,"errorMessage":"Could not locate the folder name","messagePattern":"Could not locate the folder name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/folder-source-edits.ts","lineNumber":238,"sourceCode":"\t\tinsertionEdit,\n\t\t...getInsertImportSourceEdits({\n\t\t\tast,\n\t\t\tinput,\n\t\t\tsnapshots,\n\t\t\tprettierConfigOverride: null,\n\t\t}),\n\t];\n};\n\nconst getFolderNameAttribute = (folder: JSXElement) => {\n\tconst attribute = folder.openingElement.attributes.find(\n\t\t(candidate) =>\n\t\t\tcandidate.type === 'JSXAttribute' &&\n\t\t\tcandidate.name.type === 'JSXIdentifier' &&\n\t\t\tcandidate.name.name === 'name',\n\t);\n\tif (attribute?.type !== 'JSXAttribute') {\n\t\tthrow new Error('Could not locate the folder name');\n\t}\n\n\treturn attribute;\n};\n\nconst normalizeBlock = (source: string) => {\n\tconst lines = source.split(/\\r?\\n/);\n\twhile (lines[0]?.trim() === '') {\n\t\tlines.shift();\n\t}\n\n\twhile (lines.at(-1)?.trim() === '') {\n\t\tlines.pop();\n\t}\n\n\tconst indents = lines\n\t\t.filter((line) => line.trim() !== '')\n\t\t.map((line) => line.match(/^[\\t ]*/)?.[0] ?? '');","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/folder-source-edits.ts#L220-L256","documentation":"Thrown by getFolderNameAttribute (folder-source-edits.ts:238) when a located folder JSX element has no JSX attribute literally named `name` (a JSXAttribute with a JSXIdentifier 'name'). Rename-folder codemods rewrite this attribute's string value, so without it the rename cannot be applied.","triggerScenarios":"Executing a `rename-folder` codemod against a `<Folder>` element whose name is set via a spread (`{...props}`), a dynamic attribute (`name={folderName}` is fine as attribute but the finder only matches identifier `name` — actually it matches the attribute regardless of value; failure happens when the attribute is absent or spread in), or when the element is not really a Folder component.","commonSituations":"Root files where <Folder> props are spread from an object constant, custom Folder wrappers that forward props, or hand-minified code that renamed the attribute.","solutions":["Write the name attribute explicitly on the <Folder> element: <Folder name=\"My Folder\">","Remove props spreads ({...x}) from Folder elements in the Root file","Rename the folder manually in the editor if the source cannot be normalized"],"exampleFix":"// before\nconst folderProps = {name: \"Old Name\"};\n<Folder {...folderProps}>...</Folder>\n\n// after\n<Folder name=\"Old Name\">...</Folder>","handlingStrategy":"type-guard","validationCode":"const hasExplicitNameAttr = (folderJsx: string) =>\n  /<Folder\\s+name=\"[^\"]+\"/.test(folderJsx);\nif (!hasExplicitNameAttr(folderSnippet)) throw new Error('Folder needs a literal name attribute');","typeGuard":"const isNamedFolderElement = (el: JSXElement): el is JSXElement & {openingElement: {attributes: [JSXAttribute, ...JSXAttribute[]]}} =>\n  el.openingElement.attributes.some(\n    (a): a is JSXAttribute => a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'name',\n  );","tryCatchPattern":"try {\n  editFolderInSource({codeMod, input});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Could not locate the folder name') {\n    // ask user to add an explicit name attribute, then retry\n  }\n}","preventionTips":["Always write name=\"...\" literally on <Folder> elements","Avoid {...spread} props on Folder elements","Don't wrap Folder in custom components that forward props"],"tags":["ast","codemod","jsx","rename"],"backgroundTag":"missing-required-argument","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"}