{"record":{"id":"fba1e201a6108a85","repo":"Significant-Gravitas/AutoGPT","slug":"cannot-move-folder-into-its-own-descendant","errorCode":null,"errorMessage":"Cannot move folder into its own descendant","messagePattern":"Cannot move folder into its own descendant","errorType":"validation","errorClass":"FolderValidationError","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/library/db.py","lineNumber":1600,"sourceCode":"        FolderValidationError: If the move is invalid.\n        NotFoundError: If the folder doesn't exist.\n        DatabaseError: If there's a database error.\n    \"\"\"\n    logger.debug(f\"Moving folder #{folder_id} to parent #{target_parent_id}\")\n\n    # Authorization: update uses where={\"id\": ...} without userId,\n    # so we must verify ownership first.\n    await get_folder(folder_id, user_id)\n\n    # Authorization: FK only checks existence, not ownership.\n    # Verify the target parent belongs to this user to prevent cross-user nesting.\n    if target_parent_id:\n        await get_folder(target_parent_id, user_id)\n\n    # Validate no circular reference\n    if target_parent_id:\n        if await _is_descendant_of(target_parent_id, folder_id, user_id):\n            raise FolderValidationError(\"Cannot move folder into its own descendant\")\n\n    try:\n        folder = await prisma.models.LibraryFolder.prisma().update(\n            where={\"id\": folder_id},\n            data={\n                \"parentId\": target_parent_id,\n            },\n            include=LIBRARY_FOLDER_INCLUDE,\n        )\n    except prisma.errors.UniqueViolationError:\n        raise FolderAlreadyExistsError(\n            \"A folder with this name already exists in this location\"\n        )\n\n    if not folder:\n        raise NotFoundError(f\"Folder #{folder_id} not found\")\n\n    return library_model.LibraryFolder.from_db(","sourceCodeStart":1582,"sourceCodeEnd":1618,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/library/db.py#L1582-L1618","documentation":"Error \"Cannot move folder into its own descendant\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/features/library/db.py:1600 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the folder to a location that is not inside itself or one of its subfolders.","Restructure the folder hierarchy before moving."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}