{"record":{"id":"8f3cbdc9f3477388","repo":"remotion-dev/remotion","slug":"could-not-locate-the-new-folder","errorCode":null,"errorMessage":"Could not locate the new folder","messagePattern":"Could not locate the new folder","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/folder-source-edits.ts","lineNumber":216,"sourceCode":"\n\t\t\tinsertionEdit = getInsertionRootSourceEdit({\n\t\t\t\tinput,\n\t\t\t\tinsertion: printInsertedJsx({\n\t\t\t\t\telement: inserted as never,\n\t\t\t\t\tinput,\n\t\t\t\t\tprettierConfigOverride: null,\n\t\t\t\t}),\n\t\t\t\troot: root as never,\n\t\t\t\tnullRoot: null,\n\t\t\t\tprettierConfigOverride: null,\n\t\t\t\tinsertInside: Boolean(jsxNode.loc),\n\t\t\t});\n\t\t\treturn false;\n\t\t},\n\t});\n\n\tif (insertionEdit === null) {\n\t\tthrow new Error('Could not locate the new folder');\n\t}\n\n\treturn [\n\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' &&","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/folder-source-edits.ts#L198-L234","documentation":"Thrown at the end of getNewFolderSourceEdits (folder-source-edits.ts:216) when the recast traversal found the codemod's newly grafted `<Folder>` node nowhere: `insertionEdit` stayed null. It means the AST transformation reported a change but no JSX element containing the un-located inserted Folder child could be found to generate a text edit from.","triggerScenarios":"Calling editFolderInSource with a `new-folder` RecastCodemod where applyCodemod mutated the AST but the visited JSX nodes' children do not contain a location-less JSXElement with a resolvable folder `name` — e.g. the Folder was inserted into a non-traversable node type or the grafted node does not match the finder's shape.","commonSituations":"A stale Studio state where the folder was already created, or Root files where the parent element under which the folder is added is expressed in a way recast's visit cannot re-enter (spreads, conditional expressions).","solutions":["Reload Studio / re-read the Root file and retry creating the folder","Verify the file does not already contain the folder (duplicate insertion aborts the edit)","Add the <Folder name=\"...\"> wrapper manually around the target compositions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (getLocatedItemsFromSource(input).some(isFolderNamed(codeMod))) {\n  return; // folder already present; nothing to create\n}","typeGuard":null,"tryCatchPattern":"try {\n  editFolderInSource({codeMod, input});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Could not locate the new folder') {\n    // retry once after reloading the file, else instruct manual edit\n  }\n}","preventionTips":["Don't trigger duplicate new-folder actions for the same name","Keep the <Folder> insertion point as a literal JSX child","Reload Studio state after external file edits"],"tags":["ast","codemod","folder","remotion-studio"],"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"}