{"record":{"id":"6bc890a8686d3a5d","repo":"iflytek/astron-agent","slug":"repo-file-not-exist","errorCode":"REPO_FILE_NOT_EXIST","errorMessage":"REPO_FILE_NOT_EXIST","messagePattern":"REPO_FILE_NOT_EXIST","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java","lineNumber":2190,"sourceCode":"        }\n        recursiveFindFatherPath(fileDirectoryTree.getAppId(), fileId, fileDirectoryTreePathList);\n        Collections.reverse(fileDirectoryTreePathList);\n        return fileDirectoryTreePathList;\n    }\n\n\n    /**\n     * Enable or disable a file in the repository\n     *\n     * @param id file directory tree ID\n     * @param enabled enable status (1=enabled, 0=disabled)\n     * @throws BusinessException if file does not exist or access is denied\n     */\n    @Transactional\n    public void enableFile(Long id, Integer enabled) {\n        FileDirectoryTree fileDirectoryTree = fileDirectoryTreeService.getById(id);\n        if (fileDirectoryTree == null || fileDirectoryTree.getIsFile() != 1) {\n            throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);\n        }\n        FileInfoV2 fileInfoV2 = this.getById(fileDirectoryTree.getFileId());\n        if (fileInfoV2 == null) {\n            throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);\n        }\n\n        Repo repo = repoService.getById(fileInfoV2.getRepoId());\n        if (repo != null) {\n            try {\n                dataPermissionCheckTool.checkRepoBelong(repo);\n            } catch (Exception e) {\n                log.warn(\"Unauthorized operation detected, uid={}, fileDirectoryTreeId={}\", UserInfoManagerHandler.getUserId(), id);\n                throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);\n            }\n        }\n\n        try {\n            dataPermissionCheckTool.checkFileBelong(fileInfoV2);","sourceCodeStart":2172,"sourceCodeEnd":2208,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java#L2172-L2208","documentation":"enableFile(id, enabled) toggles a file's enabled state. It throws BusinessException(REPO_FILE_NOT_EXIST) when the FileDirectoryTree row is missing or the node is not a file (isFile != 1). Folders and nonexistent ids cannot be enabled/disabled — only actual file nodes qualify.","triggerScenarios":"Calling enableFile with a tree-node id that doesn't exist, or with the id of a FOLDER node (isFile==0) — e.g. a UI bulk-enable accidentally including folder rows, or a stale id after deletion.","commonSituations":"Batch scripts iterate tree ids assuming all are files; client keeps a stale selection list after folders/files were deleted or reorganized; wrong id namespace (folder id passed where a file id is required).","solutions":["Confirm the id refers to an existing tree node with isFile==1 before calling enableFile.","Filter the id list to file nodes only (exclude nodes with isFile != 1) in bulk operations.","Refresh the client's file tree so deleted ids are removed from any pending enable/disable queue."],"exampleFix":"// before\nfor (Long id : selectedIds) {\n    fileInfoV2Service.enableFile(id, 1); // id may be a folder\n}\n// after\nfor (Long id : selectedIds) {\n    FileDirectoryTree node = fileDirectoryTreeService.getById(id);\n    if (node != null && node.getIsFile() == 1) {\n        fileInfoV2Service.enableFile(id, 1);\n    }\n}","handlingStrategy":"validation","validationCode":"FileDirectoryTree node = fileDirectoryTreeService.getById(id);\nif (node == null || node.getIsFile() != 1) {\n    // skip: not an enableable file node\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    fileInfoV2Service.enableFile(id, enabled);\n} catch (BusinessException e) {\n    if (\"REPO_FILE_NOT_EXIST\".equals(e.getCode())) {\n        // remove id from selection and notify user\n    }\n}","preventionTips":["Filter bulk selections to nodes with isFile==1.","Refresh selection lists after tree changes to drop deleted ids.","Validate id type/namespace at the call site before toggling."],"tags":["resource-not-found","validation","state-toggle"],"backgroundTag":"resource-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}