{"record":{"id":"f313b9dd246be935","repo":"iflytek/astron-agent","slug":"workflow-import-failed-f313b9","errorCode":"WORKFLOW_IMPORT_FAILED","errorMessage":"WORKFLOW_IMPORT_FAILED","messagePattern":"WORKFLOW_IMPORT_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowExportService.java","lineNumber":266,"sourceCode":"\n    private ApiResult<WorkflowImportResponse> persistImportedWorkflow(\n            Workflow wf, WorkflowImportReport report) {\n        wf.setCreateTime(new Date());\n        wf.setUpdateTime(new Date());\n        if (wf.getSource() == null) {\n            wf.setSource(0);\n        }\n        if (StringUtils.isBlank(wf.getAvatarColor())) {\n            wf.setAvatarColor(\"#FFEAD5\");\n        }\n        if (StringUtils.isBlank(wf.getAvatarIcon())) {\n            wf.setAvatarIcon(\"icon/common/emojiitem_00_10@2x.png\");\n        }\n        // All local writes participate in importWorkflowFromYaml's transaction.\n        Long spaceId = SpaceInfoUtil.getSpaceId();\n        wf.setSpaceId(spaceId);\n        if (!workflowService.save(wf)) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);\n        }\n        Integer botId = botUtil.syncToSparkDatabase(\n                wf, UserInfoManagerHandler.getUserId(), spaceId);\n        JSONObject jsonData = new JSONObject();\n        jsonData.put(\"botId\", botId);\n        wf.setExt(jsonData.toJSONString());\n        if (!workflowService.updateById(wf)) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);\n        }\n        log.info(\n                \"workflow import dependency resolution completed, flowId={}, total={}, resolved={}, unresolved={}, ambiguous={}\",\n                wf.getFlowId(), report.getTotal(), report.getResolved(), report.getUnresolved(),\n                report.getAmbiguous());\n        WorkflowImportResponse response = new WorkflowImportResponse();\n        org.springframework.beans.BeanUtils.copyProperties(wf, response);\n        response.setImportReport(report);\n        return ApiResult.success(response);\n    }","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowExportService.java#L248-L284","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nif (!workflowService.save(wf)) {\n    throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);\n}\n// after\nif (!workflowService.save(wf)) {\n    log.error(\"workflow import save failed, flowId={}, spaceId={}\", wf.getFlowId(), spaceId);\n    throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);\n}","handlingStrategy":"try-catch","validationCode":"Long spaceId = SpaceInfoUtil.getSpaceId();\nif (spaceId == null) throw new BusinessException(ResponseEnum.SPACE_NOT_EXIST); // pre-validate before save","typeGuard":null,"tryCatchPattern":"try {\n    importService.importWorkflowFromYaml(yaml);\n} catch (BusinessException e) {\n    if (ResponseEnum.WORKFLOW_IMPORT_FAILED.equals(e.getResponseEnum())) {\n        log.error(\"import persist failed; check DB logs and space context\");\n    }\n}","preventionTips":["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"],"tags":["database","mybatis-plus","import"],"backgroundTag":"database-write-failed","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"}