{"record":{"id":"f58de70842335227","repo":"remotion-dev/remotion","slug":"could-not-find-getcompositionorfolderlabel-trans-f58de7","errorCode":null,"errorMessage":"Could not find ${getCompositionOrFolderLabel(transformation.destination.target)} as a reorder target","messagePattern":"Could not find (.+?) as a reorder target","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/recast-mods.ts","lineNumber":650,"sourceCode":"\t\tvisitJSXElement(astPath) {\n\t\t\tvisitJsxElement(astPath as unknown as recast.types.NodePath);\n\t\t\treturn false;\n\t\t},\n\t});\n\n\tif (source === null) {\n\t\tthrow new Error(\n\t\t\t`Could not find ${getCompositionOrFolderLabel(transformation.source)} as a direct JSX child`,\n\t\t);\n\t}\n\n\tconst sourceItem = source as LocatedItem;\n\tif (\n\t\t(transformation.destination.type === 'before' ||\n\t\t\ttransformation.destination.type === 'after') &&\n\t\ttarget === null\n\t) {\n\t\tthrow new Error(\n\t\t\t`Could not find ${getCompositionOrFolderLabel(transformation.destination.target)} as a reorder target`,\n\t\t);\n\t}\n\n\tif (\n\t\ttransformation.destination.type === 'folder' &&\n\t\tdestinationFolder === null\n\t) {\n\t\tconst folderPath = [\n\t\t\ttransformation.destination.parentName,\n\t\t\ttransformation.destination.folderName,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join('/');\n\t\tthrow new Error(`Could not find folder \"${folderPath}\"`);\n\t}\n\n\tif (target !== null && (target as LocatedItem).node === sourceItem.node) {","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/remotion-dev/remotion/blob/a6a7485a9aeb04219510fbe4874f8941486424df/packages/studio-codemods/src/recast-mods.ts#L632-L668","documentation":"moveCompositionOrFolder applies a codemod transformation that reorders a composition or folder relative to a named target. Before mutating the AST it walks the JSX tree to locate the source item and the reorder target. If the destination is 'before' or 'after' but no JSX element matching transformation.destination.target exists as a direct child, this error is thrown because the reorder cannot be performed.","triggerScenarios":"Calling applyCodemod with a move transformation whose destination.type is 'before' or 'after' and whose destination.target (composition/folder name) does not match any direct JSX child in the composition file — e.g. the target composition was renamed, deleted, lives in a different folder, or the name was mistyped.","commonSituations":"Stale studio state after a composition was renamed on disk while the codemod request still references the old name; hand-written codemod scripts with a wrong target name; target nested inside a folder rather than being a direct sibling of the source.","solutions":["Check that the target composition/folder name in the transformation destination exactly matches an existing direct JSX child (folder wrapper or composition element) in the file","Re-read the composition file and regenerate the transformation from current studio state instead of cached state","If the target may be absent, skip the move or fall back to destination.type 'root' instead of 'before'/'after'"],"exampleFix":"// before\nawait applyCodemod({transformation: {source: {...}, destination: {type: 'after', target: {type: 'composition', name: 'OldName'}}}});\n// after\n// verify the target exists first, or use the current name\nawait applyCodemod({transformation: {source: {...}, destination: {type: 'after', target: {type: 'composition', name: 'NewName'}}}});","handlingStrategy":"validation","validationCode":"const names = collectDirectChildNames(compositionAst);\nif (!names.includes(targetName)) throw new Error(`Reorder target \"${targetName}\" not found in file`);","typeGuard":"const hasTarget = (items: {name: string}[], target: string) => items.some((i) => i.name === target);","tryCatchPattern":"try {\n  await applyCodemod({transformation});\n} catch (e) {\n  if (String(e).includes('as a reorder target')) {\n    // fall back: move to root or skip\n  } else throw e;\n}","preventionTips":["Regenerate transformations from freshly read composition state, never cached names","Verify the target is a direct JSX child of the same parent as the source","Handle renames by updating transformation targets when compositions are renamed"],"tags":["codemod","ast","studio"],"backgroundTag":"codemod-target-not-found","analyzedSha":"a6a7485a9aeb04219510fbe4874f8941486424df","analyzedAt":"2026-09-02T16:25:19.997Z","contentChangedAt":"2026-09-02T16:25:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}