iflytek/astron-agent · error · BusinessException

REPO_FILE_DELETE_FAILED

REPO_FILE_DELETE_FAILED

Error message

ResponseEnum.REPO_FILE_DELETE_FAILED

What it means

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.

Solutions

  1. Inspect the logged 'Failed to delete file, message:{}' for the upstream error detail.
  2. Re-check whether the doc/chunk still exists upstream — if already deleted, treat the operation as successful.
  3. Validate ragType and ragflowDatasetId (applyRagflowDatasetId output) before retrying.
  4. Retry the delete once the upstream service is healthy; reconcile upstream index state if it is permanently divergent.

Example fix

// before
KnowledgeResponse response = knowledgeV2ServiceCallHandler.deleteDocOrChunk(request);
if (response.getCode() != 0) {
    throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);
}

// after
KnowledgeResponse response = knowledgeV2ServiceCallHandler.deleteDocOrChunk(request);
if (response.getCode() != 0) {
    if (isAlreadyDeleted(response)) { // e.g. 'doc not found' upstream
        log.info("doc {} already deleted upstream, ignoring", request.getDocId());
    } else {
        throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the doc still exists upstream before delete
// (console DB row + upstream listing agree)

Try / catch

try {
    knowledgeService.deleteFile(docId, chunkIds);
} catch (BusinessException e) {
    if (ResponseEnum.REPO_FILE_DELETE_FAILED.getCode().equals(e.getCode())) {
        // check if already deleted upstream -> treat as success; else retry after recovery
    } else { throw e; }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

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

                }
                FileInfoV2 fileInfoV2 = fileInfoV2Service.getOnly(new QueryWrapper<FileInfoV2>().eq("uuid", docId));
                if (fileInfoV2 == null) {
                    throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);
                }
                if (ProjectContent.isCbgRagCompatible(fileInfoV2.getSource())) {
                    request.setRagType(fileInfoV2.getSource());
                    if (CollectionUtils.isEmpty(request.getChunkIds())) {
                        needDelete = false;
                    }
                }
                if (!applyRagflowDatasetIdForDelete(request, fileInfoV2, repoIdToDatasetId)) {
                    continue;
                }
                if (needDelete) {
                    KnowledgeResponse response = knowledgeV2ServiceCallHandler.deleteDocOrChunk(request);
                    if (response.getCode() != 0) {
                        log.error("Failed to delete file, message:{}", response.getMessage());
                        throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);
                    }
                }
            }
        }
    }

    /**
     * Delete specific knowledge chunks from the external knowledge base
     *
     * @param docId the document ID containing the chunks
     * @param deleteChunkIds JSON array containing chunk IDs to be deleted
     * @throws BusinessException if file not found or deletion operations fail
     */
    public void deleteKnowledgeChunks(String docId, JSONArray deleteChunkIds) {
        if (!deleteChunkIds.isEmpty()) { // Delete documents
            KnowledgeRequest request = new KnowledgeRequest();
            request.setDocId(docId);
            request.setChunkIds(deleteChunkIds.toJavaList(String.class));

View on GitHub (pinned to 5e758547a8)