iflytek/astron-agent · error · BusinessException
REPO_FILE_DELETE_FAILED
REPO_FILE_DELETE_FAILED
Error message
REPO_FILE_DELETE_FAILED
What it means
BusinessException(REPO_FILE_DELETE_FAILED) thrown when the remote knowledge-service delete call returns a non-zero code or an unparsable/missing code field. The service builds a URL with authorization headers, performs OkHttpUtil.get, parses the JSON response, and treats code != 0 as a failed deletion. The local transaction is aborted so the tree node is not removed while the backend content persists.
Solutions
- Inspect the remote response body (log 'resp') to see the actual code/message returned by the knowledge service.
- Verify the Authorization header is valid and not expired; re-authenticate and retry.
- Check the remote knowledge service health and whether the target record still exists there.
- Retry the delete after the remote service recovers; if it was already deleted remotely, remove the local tree node manually or make the call idempotent.
Example fix
// before: any non-zero code aborts
if (jsonObject.get("code") == null || jsonObject.getIntValue("code") != 0) {
throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);
}
// after: tolerate already-deleted remote record
int code = jsonObject.getIntValue("code");
if (code != 0 && code != REMOTE_ALREADY_DELETED_CODE) {
log.error("remote delete failed, code={}, resp={}", code, resp);
throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);
} Defensive patterns
Strategy: retry
Validate before calling
// pre-check remote reachability before issuing delete
const health = await fetch(`${knowledgeBaseUrl}/health`).then(r => r.ok).catch(() => false);
if (!health) throw new Error('knowledge service unavailable, defer delete'); Try / catch
try {
await repoApi.deleteFile(id);
} catch (e) {
if (e.code === 'REPO_FILE_DELETE_FAILED') {
// retry with backoff; remote may be transiently down
await retry(() => repoApi.deleteFile(id), { retries: 3, backoffMs: 2000 });
return;
}
throw e;
} Prevention
- Monitor remote knowledge-service availability before delete operations.
- Ensure the Authorization header is fresh and forwarded correctly.
- Log the remote response body on failure for quick diagnosis.
- Make remote deletes idempotent to tolerate already-deleted records.
When it happens
Trigger: Deleting a repo file whose backing knowledge data lives in the remote service: the remote responds with code != 0 (deletion refused, record busy, auth rejected) or returns a body without a 'code' field (HTML error page, gateway timeout body).
Common situations: Remote knowledge service down or redeploying; invalid/expired Authorization header forwarded from the client; network gateway returning 502 HTML that fails the code==0 check; remote record already deleted (idempotent delete conflict).
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- sandbox-exec failed: HTTP
- Skill resource download failed: HTTP
- Skill resource download returned empty body
- exceeds size limit
- SYSTEM_ERROR
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/b40954374b737182.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java:2250
* @param tag file source tag (Spark RAG or others)
* @param repoId repository ID
* @param request HTTP servlet request for authentication
* @throws BusinessException if file deletion fails or repository access is denied
*/
@Transactional
public void deleteFileDirectoryTree(String id, String tag, Long repoId, HttpServletRequest request) {
if (ProjectContent.isSparkRagCompatible(tag)) {
// Spark Delete
String url = apiUrl.getDeleteXinghuoDatasetFileUrl() + "?datasetId=" + repoId + "&fileId=" + id;
HashMap<String, String> header = new HashMap<>();
String authorization = request.getHeader("Authorization");
if (StringUtils.isNotBlank(authorization)) {
header.put("Authorization", authorization);
}
String resp = OkHttpUtil.get(url, header);
JSONObject jsonObject = JSONObject.parseObject(resp);
if (jsonObject.get("code") == null || jsonObject.getIntValue("code") != 0) {
throw new BusinessException(ResponseEnum.REPO_FILE_DELETE_FAILED);
}
} else {
Repo repo = repoService.getById(repoId);
if (repo != null) {
dataPermissionCheckTool.checkRepoBelong(repo);
}
Long fileId = Long.valueOf(id);
FileDirectoryTree fileDirectoryTree = fileDirectoryTreeService.getById(fileId);
if (fileDirectoryTree == null || fileDirectoryTree.getIsFile() != 1) {
throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);
}
fileDirectoryTreeService.removeById(fileId);
List<Long> ids = new ArrayList<>();
ids.add(fileDirectoryTree.getFileId());
// Add back billing metrics after deletionView on GitHub (pinned to 5e758547a8)