{"record":{"id":"fe905debe4928ded","repo":"iflytek/astron-agent","slug":"file-not-found","errorCode":null,"errorMessage":"File not found","messagePattern":"File not found","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java","lineNumber":1960,"sourceCode":"        FileDirectoryTree fileDirectoryTree = fileDirectoryTreeService.getById(folderVO.getId());\n        fileDirectoryTree.setName(folderVO.getName());\n        fileDirectoryTree.setUpdateTime(LocalDateTime.now());\n        fileDirectoryTreeService.updateById(fileDirectoryTree);\n    }\n\n\n    /**\n     * Update file name in directory tree and file info table\n     *\n     * @param folderVO file update parameters containing ID and new name\n     * @throws RuntimeException if file is not found\n     * @throws BusinessException if file access is denied\n     */\n    public void updateFile(CreateFolderVO folderVO) {\n        FileDirectoryTree fileDirectoryTree = fileDirectoryTreeService.getById(folderVO.getId());\n        Long spaceId = SpaceInfoUtil.getSpaceId();\n        if (fileDirectoryTree == null) {\n            throw new RuntimeException(\"File not found\");\n        }\n        FileInfoV2 fileInfoV2 = this.getById(fileDirectoryTree.getFileId());\n        if (fileInfoV2 == null) {\n            throw new RuntimeException(\"File not found\");\n        }\n        if (null == spaceId) {\n            dataPermissionCheckTool.checkFileBelong(fileInfoV2);\n        }\n\n        fileDirectoryTree.setName(folderVO.getName());\n        fileDirectoryTree.setUpdateTime(LocalDateTime.now());\n        fileDirectoryTreeService.updateById(fileDirectoryTree);\n\n        fileInfoV2.setName(folderVO.getName());\n        fileInfoV2.setUpdateTime(new Timestamp(System.currentTimeMillis()));\n        this.updateById(fileInfoV2);\n    }\n","sourceCodeStart":1942,"sourceCodeEnd":1978,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java#L1942-L1978","documentation":"updateFile loads the FileDirectoryTree node by folderVO.id; when fileDirectoryTreeService.getById returns null it throws a plain RuntimeException(\"File not found\") (not a BusinessException). The tree node targeted for rename/update does not exist, so the update cannot proceed.","triggerScenarios":"Calling updateFile with an id that has no row in the file-directory-tree table: deleted node, stale id in the client, wrong id field passed (e.g. fileInfoV2 id instead of tree-node id), or id from another environment.","commonSituations":"Two users edit concurrently and one deletes the file while the other saves a rename; frontend cache holds ids from a previous session; scripts hardcode ids after a data migration.","solutions":["Verify the FileDirectoryTree id exists (via file-list API) before calling updateFile.","Refresh the file tree in the client so stale ids are replaced with current ones.","Ensure the id passed is the tree-node id (fileDirectoryTree.id), not the FileInfoV2 file id."],"exampleFix":"// before\nCreateFolderVO vo = new CreateFolderVO();\nvo.setId(deletedNodeId);\nfileInfoV2Service.updateFile(vo);\n// after\nLong nodeId = fetchCurrentTreeNodeId(fileName);\nCreateFolderVO vo = new CreateFolderVO();\nvo.setId(nodeId);\nfileInfoV2Service.updateFile(vo);","handlingStrategy":"try-catch","validationCode":"FileDirectoryTree node = fileDirectoryTreeService.getById(vo.getId());\nif (node == null) {\n    // refresh tree, abort update\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    fileInfoV2Service.updateFile(vo);\n} catch (RuntimeException e) {\n    if (\"File not found\".equals(e.getMessage())) {\n        // refresh file tree and inform user the file no longer exists\n    }\n}","preventionTips":["Pass the tree-node id (not the FileInfoV2 id) to updateFile.","Refresh the tree after any concurrent edit/delete to avoid stale ids.","Handle concurrent-delete conflicts: on save failure, reload before retrying."],"tags":["resource-not-found","entity","runtime-exception"],"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"}