iflytek/astron-agent · error · BusinessException
WORKFLOW_IMPORT_FAILED
WORKFLOW_IMPORT_FAILED
Error message
WORKFLOW_IMPORT_FAILED
What it means
During YAML workflow import, persistImportedWorkflow inserts the new Workflow row via workflowService.save(wf); when MyBatis-Plus reports the insert affected no rows, it throws BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED). This error means the workflow record could not be persisted as the first step of the import transaction.
Solutions
- Check DB logs / enable MyBatis-Plus SQL logging to see why the INSERT failed
- Verify SpaceInfoUtil.getSpaceId() resolves to a valid space the user belongs to
- Check unique constraints on workflow table (name/flowId per space) and rename the imported workflow if colliding
- Confirm database connectivity and recent schema migrations
Example fix
// before
if (!workflowService.save(wf)) {
throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
}
// after
if (!workflowService.save(wf)) {
log.error("workflow import save failed, flowId={}, spaceId={}", wf.getFlowId(), spaceId);
throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
} Defensive patterns
Strategy: try-catch
Validate before calling
Long spaceId = SpaceInfoUtil.getSpaceId(); if (spaceId == null) throw new BusinessException(ResponseEnum.SPACE_NOT_EXIST); // pre-validate before save
Try / catch
try {
importService.importWorkflowFromYaml(yaml);
} catch (BusinessException e) {
if (ResponseEnum.WORKFLOW_IMPORT_FAILED.equals(e.getResponseEnum())) {
log.error("import persist failed; check DB logs and space context");
}
} Prevention
- Ensure user session and space context are set before import
- Watch for workflow name/flowId uniqueness collisions in the target space
- Keep workflow-table schema migrations in sync
When it happens
Trigger: workflowService.save(wf) returns false — DB insert fails, e.g. duplicate unique key, null constraint violation on a column, DB connection failure, or space/user context missing (spaceId null where required).
Common situations: Importing into a space that doesn't exist or the user lacks membership; DB schema mismatch after migration; workflow name/flowId uniqueness constraints in the target space; database outage or pool exhaustion.
Related errors
- INTERNAL_SERVER_ERROR
- DATABASE_IMPORT_FAILED
- CREATE_BOT_FAILED
- UPDATE_BOT_FAILED
- NOTIFICATION_MARK_READ_FAILED
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/f313b9dd246be935.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowExportService.java:266
private ApiResult<WorkflowImportResponse> persistImportedWorkflow(
Workflow wf, WorkflowImportReport report) {
wf.setCreateTime(new Date());
wf.setUpdateTime(new Date());
if (wf.getSource() == null) {
wf.setSource(0);
}
if (StringUtils.isBlank(wf.getAvatarColor())) {
wf.setAvatarColor("#FFEAD5");
}
if (StringUtils.isBlank(wf.getAvatarIcon())) {
wf.setAvatarIcon("icon/common/emojiitem_00_10@2x.png");
}
// All local writes participate in importWorkflowFromYaml's transaction.
Long spaceId = SpaceInfoUtil.getSpaceId();
wf.setSpaceId(spaceId);
if (!workflowService.save(wf)) {
throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
}
Integer botId = botUtil.syncToSparkDatabase(
wf, UserInfoManagerHandler.getUserId(), spaceId);
JSONObject jsonData = new JSONObject();
jsonData.put("botId", botId);
wf.setExt(jsonData.toJSONString());
if (!workflowService.updateById(wf)) {
throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
}
log.info(
"workflow import dependency resolution completed, flowId={}, total={}, resolved={}, unresolved={}, ambiguous={}",
wf.getFlowId(), report.getTotal(), report.getResolved(), report.getUnresolved(),
report.getAmbiguous());
WorkflowImportResponse response = new WorkflowImportResponse();
org.springframework.beans.BeanUtils.copyProperties(wf, response);
response.setImportReport(report);
return ApiResult.success(response);
}View on GitHub (pinned to 5e758547a8)