iflytek/astron-agent · error · BusinessException
REPO_CREATE_RAGFLOW_FAILED
REPO_CREATE_RAGFLOW_FAILED
Error message
RAGFlow returned blank datasetId
What it means
extractDatasetId() parses the response body of a RAGFlow dataset-creation API call and reads the datasetId field. If the parsed JSON object lacks the field or it is blank, it throws BusinessException(ResponseEnum.REPO_CREATE_RAGFLOW_FAILED, "RAGFlow returned blank datasetId"). It indicates the knowledge-base creation request reached RAGFlow but the response did not contain the expected identifier.
Solutions
- Log the full RAGFlow response body before extraction and inspect whether it actually contains a datasetId or an embedded error message.
- Verify the RAGFlow API key and tenant configuration; auth failures can surface as success-shaped empty payloads.
- Check the RAGFlow version's API docs for the dataset-creation response schema and update DATASET_ID_FIELD if the field was renamed.
- If RAGFlow returned an embedded error, surface that message to the caller instead of the generic blank-datasetId error.
Example fix
// before
String datasetId = dataObj == null ? null : dataObj.getString(DATASET_ID_FIELD);
// after
String datasetId = dataObj == null ? null : dataObj.getString(DATASET_ID_FIELD);
if (StringUtils.isBlank(datasetId) && dataObj != null && dataObj.containsKey("code") && dataObj.getIntValue("code") != 0) {
log.error("RAGFlow create dataset failed: {}", dataObj.toJSONString());
} Defensive patterns
Strategy: try-catch
Validate before calling
JSONObject resp = toJsonObject(ragflowCreateResponse);
if (resp == null || StringUtils.isBlank(resp.getString("datasetId"))) {
throw new Error('RAGFlow response has no datasetId: ' + JSON.toJSONString(resp));
} Type guard
boolean hasDatasetId(Object data) {
JSONObject o = (data instanceof JSONObject) ? (JSONObject) data : null;
return o != null && StringUtils.isNotBlank(o.getString("datasetId"));
} Try / catch
try {
String id = createRagflowDataset(req);
} catch (BusinessException e) {
log.error('RAGFlow create dataset failed: {}', e.getMessage());
// inspect full RAGFlow body for embedded error before retrying
} Prevention
- Log the complete RAGFlow response body on every create call so blank-datasetId cases are diagnosable.
- Verify RAGFlow API key/tenant configuration in the deployment environment.
- Pin the RAGFlow version and re-check the create-dataset response schema on upgrades.
When it happens
Trigger: Creating a RAGFlow-backed knowledge repository where the create-dataset HTTP call returns 200 but data.datasetId is missing, null, or an empty string in the JSON payload.
Common situations: RAGFlow returns an error payload wrapped in a 200 response (its error inside data/message instead of HTTP status); RAGFlow version changed the response field name; wrong RAGFlow API key/tenant causing a success-shaped but empty body; network proxy mangling the response.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- REPO_KNOWLEDGE_ADD_FAILED
- REPO_STATUS_ILLEGAL
- REPO_NOT_EXIST
- REPO_KNOWLEDGE_MODIFY_FAILED
- REPO_FILE_DELETE_FAILED
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/62abb861a65c17cb.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/handler/KnowledgeV2ServiceCallHandler.java:63
Map<String, String> headers = buildKnowledgeHeaders(ProjectContent.FILE_SOURCE_RAG_FLOW_RAG_STR);
DatasetCreateRequest req = new DatasetCreateRequest(name, description);
String reqBody = JSON.toJSONString(req);
log.info("createRagflowDataset url = {}, name = {}", url, name);
String resp = postJson(url, headers, reqBody);
log.info("createRagflowDataset response = {}", resp);
KnowledgeResponse parsed = JSON.parseObject(resp, KnowledgeResponse.class);
if (parsed == null || parsed.getCode() == null || parsed.getCode() != 0) {
String msg = (parsed == null) ? "blank response" : parsed.getMessage();
throw new BusinessException(ResponseEnum.REPO_CREATE_RAGFLOW_FAILED, msg);
}
return extractDatasetId(parsed.getData());
}
private String extractDatasetId(Object data) {
JSONObject dataObj = toJsonObject(data);
String datasetId = dataObj == null ? null : dataObj.getString(DATASET_ID_FIELD);
if (StringUtils.isBlank(datasetId)) {
throw new BusinessException(ResponseEnum.REPO_CREATE_RAGFLOW_FAILED,
"RAGFlow returned blank datasetId");
}
return datasetId;
}
private JSONObject toJsonObject(Object data) {
if (data instanceof JSONObject) {
return (JSONObject) data;
}
if (data instanceof String) {
return JSON.parseObject((String) data);
}
throw new BusinessException(ResponseEnum.REPO_CREATE_RAGFLOW_FAILED,
"RAGFlow returned non-object data");
}
/**
* Document parsing and chunkingView on GitHub (pinned to 5e758547a8)