{"record":{"id":"85ff95e605b6f2b2","repo":"remotion-dev/remotion","slug":"could-not-find-getcompositionorfolderlabel-trans","errorCode":null,"errorMessage":"Could not find ${getCompositionOrFolderLabel(transformation.source)} as a direct JSX child","messagePattern":"Could not find (.+?) as a direct JSX child","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/recast-mods.ts","lineNumber":639,"sourceCode":"\t\t\t\t\tastPath.get('children', index) as recast.types.NodePath,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (folderName !== null) {\n\t\t\tfolderStack.pop();\n\t\t}\n\t};\n\n\trecast.types.visit(file, {\n\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","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/remotion-dev/remotion/blob/a6a7485a9aeb04219510fbe4874f8941486424df/packages/studio-codemods/src/recast-mods.ts#L621-L657","documentation":"moveCompositionOrFolder implements the Studio codemod that moves a composition or folder within the Root JSX. It scans all JSX elements for a direct JSX child matching the transformation source (composition id or folder name+parent). If no match is found as a direct child of a JSXElement/JSXFragment, it throws 'Could not find <label> as a direct JSX child'.","triggerScenarios":"Running a move codemod whose source composition id or folder name/parent does not match any direct JSX child in the file — e.g. the composition was renamed/deleted, lives in a different file, is conditionally rendered, or the folder path (parentName/folderName) doesn't match the actual nesting.","commonSituations":"Stale Studio state after renaming a composition in code without reloading; composition defined in another file than the one the codemod targets; the element is nested deeper than direct-child level via wrappers; duplicate folder names causing path mismatch.","solutions":["Verify the composition id or folder name/parent in the transformation matches the actual JSX in the Root file (check spelling and nesting path)","Ensure the composition is a direct child of a JSXElement or fragment in the targeted file (remove wrapper components/indirection)","Reopen/reload the Studio so the codemod targets the current file contents after any manual edits","If the composition lives in another Root file, run the move from the correct file/context"],"exampleFix":"// before (codemod asked to move id=\"MyComp\" but file contains)\n<Composition id=\"my-comp\" ... />\n// after\n<Composition id=\"MyComp\" ... />  // align the id (or retry the move) so source matches a direct JSX child","handlingStrategy":"validation","validationCode":"const existsAsDirectChild = (fileAst: File, compositionId: string): boolean =>\n  recast.types.visit(fileAst, {\n    visitJSXElement(p) {\n      const parent = p.parentPath?.node;\n      const isDirect = parent && ['JSXElement','JSXFragment'].includes(parent.type);\n      if (isDirect && getCompositionIdFromJSXElement(p.node as JSXElement) === compositionId) return false;\n      this.traverse(p);\n      return false;\n    },\n  }) ?? false;","typeGuard":"const isDirectJsxChild = (node: JSXElement, parent: {type: string; children: unknown[]} | undefined): boolean =>\n  (parent?.type === 'JSXElement' || parent?.type === 'JSXFragment') && parent.children.includes(node);","tryCatchPattern":"try {\n  applyCodemod(file, transformation);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('as a direct JSX child')) {\n    console.warn(`Move skipped: ${err.message}. Check the composition/folder still exists in this file.`);\n    return {applied: false};\n  }\n  throw err;\n}","preventionTips":["Refresh Studio state after renaming or deleting compositions before running moves","Confirm the source id/folder path matches the file's actual JSX nesting","Keep compositions as direct children of a fragment/element, not behind wrapper components","Run moves against the file that actually contains the element"],"tags":["codemod","ast","jsx","recast"],"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-14T05:17:10.506Z"}