remotion-dev/remotion · error · Error
Could not locate the folder to rename
Error message
Could not locate the folder to rename
What it means
editFolderInSource in @remotion/studio-codemods edits a folder in the source of a composition. For a 'rename-folder' codemod it first resolves the folder node from the AST; if no folder node could be located (folder === null), it refuses to proceed with this error instead of guessing at edits. This is a lookup failure, not a parse failure.
Solutions
- Verify the folder still exists in the composition source file and that its name/id matches what the codemod input references.
- Re-open/refresh the studio state so folder references are re-resolved from current source.
- Re-parse the file and confirm the folder node is found before calling editFolderInSource (run the same lookup your pipeline uses).
- If the file was hand-edited, revert or fix the edit so the folder markup is intact, then retry the rename.
Example fix
// before (folder id stale)
await editFolderInSource({input: src, codeMod: {type: 'rename-folder', folderId: 'old-id', newName: 'x'}});
// after (resolve the real folder id first)
const folder = locateFolder(src, 'My Folder');
if (!folder) throw new Error('Folder missing from source');
await editFolderInSource({input: src, codeMod: {type: 'rename-folder', folderId: folder.id, newName: 'x'}}); Defensive patterns
Strategy: validation
Validate before calling
const folder = sourceFile && locateFolderNode(sourceFile, folderRef);
if (!folder) throw new Error(`Folder "${folderRef}" not found in source; refresh state before rename`); Type guard
const isFolderLocated = (f: unknown): f is LocatedFolder => Boolean(f) && typeof f === 'object' && 'node' in (f as object);
Try / catch
try {
await editFolderInSource({input, codeMod});
} catch (e) {
if (e instanceof Error && e.message === 'Could not locate the folder to rename') {
console.warn('Folder missing; reloading studio state');
await refreshSourceState();
} else throw e;
} Prevention
- Re-resolve folder references from the current file before each codemod run
- Avoid concurrent manual edits to files a codemod will touch
- Validate folder existence in source as a pre-step in your pipeline
When it happens
Trigger: Calling editFolderInSource with a 'rename-folder' codeMod where the folder ID/name passed in the input does not match any folder node found in the parsed source AST, so folder resolution returns null.
Common situations: Renaming a folder in Remotion Studio after the underlying file was edited manually or reformatted so the folder node no longer matches; stale folder references in studio state pointing at a folder that was deleted or whose markup changed.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Could not find folder
- Could not find target folder
- Could not locate the composition component root
- Could not locate the destination folder
- Could not locate the new folder
AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18).
Data as JSON: /api/errors/ad2fed9b852a717e.
Report an issue: GitHub.
Appendix: source
Thrown at packages/studio-codemods/src/folder-source-edits.ts:497
? getFolder({
folderName: codeMod.folderName,
items,
parentName: codeMod.parentName,
})
: null;
const {newAst, changesMade} = applyCodemod({file: ast, codeMod});
if (changesMade.length === 0) {
throw new Error(
'Unable to calculate the changes needed for this file. Edit the file manually.',
);
}
let edits: SourceEdit[];
if (codeMod.type === 'new-folder') {
edits = getNewFolderSourceEdits({ast: newAst, input});
} else if (codeMod.type === 'rename-folder') {
if (folder === null) {
throw new Error('Could not locate the folder to rename');
}
edits = [
getJsxStringAttributeValueSourceEdit({
attribute: getFolderNameAttribute(folder.node),
input,
newValue: codeMod.newName,
}),
];
} else if (codeMod.type === 'delete-folder') {
if (folder === null) {
throw new Error('Could not locate the folder to delete');
}
edits = [getDeleteFolderSourceEdit({input, located: folder})];
} else {
edits = getMoveSourceEdits({codeMod, input, items});
}View on GitHub (pinned to 46a3a6bf13)