iflytek/astron-agent · error · BusinessException

REPO_FOLDER_NOT_EXIST

REPO_FOLDER_NOT_EXIST

Error message

REPO_FOLDER_NOT_EXIST

What it means

BusinessException(REPO_FOLDER_NOT_EXIST) thrown at the start of deleteFolder(Long id) when the fileDirectoryTree record does not exist or its isFile flag is not 0 (i.e. it is a file, not a folder). The method requires the id to reference a directory node before it recursively collects and deletes its children.

Solutions

  1. Confirm the id refers to a directory node with isFile == 0 before invoking deleteFolder.
  2. Use the file-delete endpoint instead when the target is a file node.
  3. Handle idempotency in the client: treat 'folder not exist' on delete as already-done and refresh the tree.
  4. Check tenant/space: the record may exist but in a different workspace's tree.

Example fix

// before
await repoApi.deleteFolder(selectedId);
// after: validate node type first
const node = await repoApi.getTreeNode(selectedId);
if (!node || node.isFile !== 0) return; // nothing to delete
await repoApi.deleteFolder(selectedId);
Defensive patterns

Strategy: validation

Validate before calling

const node = await fileApi.getTreeNode(id);
if (!node || node.isFile !== 0) {
  throw new Error(`id ${id} is not a folder node`);
}

Type guard

function isFolderNode(node) {
  return node != null && node.isFile === 0;
}

Try / catch

try {
  await repoApi.deleteFolder(id);
} catch (e) {
  if (e.code === 'REPO_FOLDER_NOT_EXIST') {
    await refreshTree(); // already gone
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling deleteFolder with: an id already deleted by another user/session, a non-existent id, or the id of a file node (isFile == 1) instead of a folder.

Common situations: Folder removed concurrently in another tab while the user clicks delete; frontend mixing up file and folder ids in the tree component; retry of a previously successful delete.

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


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/4c5c1eb2a3d56fe5. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java:2301

    public void deleteFile(Long id) {
        fileDirectoryTreeService.remove(Wrappers.lambdaQuery(FileDirectoryTree.class).eq(FileDirectoryTree::getFileId, id));
        List<Long> ids = new ArrayList<>();
        ids.add(id);
        knowledgeService.deleteDoc(ids);
    }


    /**
     * Delete folder and all its contents recursively
     *
     * @param id folder ID to delete
     * @throws BusinessException if folder does not exist or repository access is denied
     */
    @Transactional
    public void deleteFolder(Long id) {
        FileDirectoryTree fileDirectoryTree = fileDirectoryTreeService.getById(id);
        if (fileDirectoryTree == null || fileDirectoryTree.getIsFile() != 0) {
            throw new BusinessException(ResponseEnum.REPO_FOLDER_NOT_EXIST);
        }
        Repo repo = repoService.getById(fileDirectoryTree.getAppId());
        if (repo != null) {
            dataPermissionCheckTool.checkRepoBelong(repo);
        }
        // Recursively find all files and directory objects under the current folder
        List<FileDirectoryTree> dirList = new ArrayList<>();
        List<FileDirectoryTree> fileList = new ArrayList<>();
        this.recursiveFindChildPath(fileDirectoryTree.getAppId(), id, dirList, fileList);
        Set<Long> delIdSet = new HashSet<>();
        delIdSet.add(id);
        for (FileDirectoryTree directoryTree : dirList) {
            delIdSet.add(directoryTree.getId());
        }
        List<Long> delDocIdList = new ArrayList<>();
        for (FileDirectoryTree directoryTree : fileList) {
            delIdSet.add(directoryTree.getId());
            delDocIdList.add(directoryTree.getFileId());

View on GitHub (pinned to 5e758547a8)