{"record":{"id":"aec2a1f2ea4b528d","repo":"iflytek/astron-agent","slug":"repo-file-delete-failed-responseenum","errorCode":"REPO_FILE_DELETE_FAILED","errorMessage":"ResponseEnum.REPO_FILE_DELETE_FAILED","messagePattern":"ResponseEnum\\.REPO_FILE_DELETE_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/KnowledgeService.java","lineNumber":1647,"sourceCode":"                }\n                FileInfoV2 fileInfoV2 = fileInfoV2Service.getOnly(new QueryWrapper<FileInfoV2>().eq(\"uuid\", docId));\n                if (fileInfoV2 == null) {\n                    throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);\n                }\n                if (ProjectContent.isCbgRagCompatible(fileInfoV2.getSource())) {\n                    request.setRagType(fileInfoV2.getSource());\n                    if (CollectionUtils.isEmpty(request.getChunkIds())) {\n                        needDelete = false;\n                    }\n                }\n                if (!applyRagflowDatasetIdForDelete(request, fileInfoV2, repoIdToDatasetId)) {\n                    continue;\n                }\n                if (needDelete) {\n                    KnowledgeResponse response = knowledgeV2ServiceCallHandler.deleteDocOrChunk(request);\n                    if (response.getCode() != 0) {\n                        log.error(\"Failed to delete file, message:{}\", response.getMessage());\n                        throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);\n                    }\n                }\n            }\n        }\n    }\n\n    /**\n     * Delete specific knowledge chunks from the external knowledge base\n     *\n     * @param docId the document ID containing the chunks\n     * @param deleteChunkIds JSON array containing chunk IDs to be deleted\n     * @throws BusinessException if file not found or deletion operations fail\n     */\n    public void deleteKnowledgeChunks(String docId, JSONArray deleteChunkIds) {\n        if (!deleteChunkIds.isEmpty()) { // Delete documents\n            KnowledgeRequest request = new KnowledgeRequest();\n            request.setDocId(docId);\n            request.setChunkIds(deleteChunkIds.toJavaList(String.class));","sourceCodeStart":1629,"sourceCodeEnd":1665,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/KnowledgeService.java#L1629-L1665","documentation":"KnowledgeService deletes documents/chunks through knowledgeV2ServiceCallHandler.deleteDocOrChunk(request). When the upstream knowledge service returns code != 0, it logs 'Failed to delete file' and throws BusinessException(REPO_FILE_DELETE_FAILED). This is a wrapper over any downstream rejection of the delete call.","triggerScenarios":"deleteDocOrChunk is rejected upstream: document or chunk already deleted (upstream returns error instead of idempotent success), invalid ragType/ragflowDatasetId on the request, upstream service outage, or permission/validation failure inside the RAG service.","commonSituations":"Double-delete from retries or concurrent users; RAGFlow dataset recreated so old datasetId invalid; upstream knowledge service degraded during maintenance; mismatch between console DB state and upstream index state.","solutions":["Inspect the logged 'Failed to delete file, message:{}' for the upstream error detail.","Re-check whether the doc/chunk still exists upstream — if already deleted, treat the operation as successful.","Validate ragType and ragflowDatasetId (applyRagflowDatasetId output) before retrying.","Retry the delete once the upstream service is healthy; reconcile upstream index state if it is permanently divergent."],"exampleFix":"// before\nKnowledgeResponse response = knowledgeV2ServiceCallHandler.deleteDocOrChunk(request);\nif (response.getCode() != 0) {\n    throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);\n}\n\n// after\nKnowledgeResponse response = knowledgeV2ServiceCallHandler.deleteDocOrChunk(request);\nif (response.getCode() != 0) {\n    if (isAlreadyDeleted(response)) { // e.g. 'doc not found' upstream\n        log.info(\"doc {} already deleted upstream, ignoring\", request.getDocId());\n    } else {\n        throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);\n    }\n}","handlingStrategy":"try-catch","validationCode":"// verify the doc still exists upstream before delete\n// (console DB row + upstream listing agree)","typeGuard":null,"tryCatchPattern":"try {\n    knowledgeService.deleteFile(docId, chunkIds);\n} catch (BusinessException e) {\n    if (ResponseEnum.REPO_FILE_DELETE_FAILED.getCode().equals(e.getCode())) {\n        // check if already deleted upstream -> treat as success; else retry after recovery\n    } else { throw e; }\n}","preventionTips":["Treat upstream 'not found' on delete as success for idempotency.","Avoid double-delete from UI double-clicks or automatic retries without dedup.","Regenerate ragflowDatasetId after dataset recreation.","Monitor upstream knowledge service health before batch deletes."],"tags":["java","ragflow","delete","upstream-error"],"backgroundTag":"upstream-api-error","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}