{"record":{"id":"66ce4fa055baf7f6","repo":"iflytek/astron-agent","slug":"8118-workflow-import-failed","errorCode":"8118","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/controller/workflow/WorkflowController.java","lineNumber":506,"sourceCode":"    @PostMapping(\"/import\")\n    @SpacePreAuth(\n            key = \"WorkflowController_importWorkflow_POST\",\n            module = \"Workflow\",\n            point = \"Workflow Import\",\n            description = \"Workflow Import\")\n    public Object importWorkflow(@RequestParam(\"file\") MultipartFile file, HttpServletRequest request) {\n        if (file == null || file.isEmpty() || file.getSize() > MAX_WORKFLOW_IMPORT_BYTES) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_DLS_UPLOAD_FAILED);\n        }\n        try (InputStream inputStream = file.getInputStream()) {\n            return workflowExportService.importWorkflowFromYaml(inputStream, request);\n        } catch (BusinessException e) {\n            log.warn(\"import workflow rejected, filename={}, code={}\",\n                    file.getOriginalFilename(), e.getCode());\n            throw e;\n        } catch (Exception e) {\n            log.error(\"import workflow failed, filename={}\", file.getOriginalFilename(), e);\n            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);\n        }\n    }\n\n    // ---------------------- Prompt Comparison (Save/List) ----------------------\n\n    @PostMapping(\"/save-comparisons\")\n    public ApiResult<String> saveComparisons(@RequestBody @NotNull List<WorkflowComparisonSaveReq> workflowComparisonReqList) {\n        return ApiResult.success(workflowService.saveComparisons(workflowComparisonReqList));\n    }\n\n    @GetMapping(\"/list-comparisons\")\n    public List<WorkflowComparison> listComparisons(@RequestParam @NotBlank String promptId) {\n        return workflowService.listComparisons(promptId);\n    }\n\n    // ---------------------- Feedback ----------------------\n\n    @PostMapping(\"/feedback\")","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/workflow/WorkflowController.java#L488-L524","documentation":"This is the catch-all branch of importWorkflow(). BusinessExceptions from YAML validation are rethrown unchanged, but any other Exception during parsing/import (malformed YAML, IO errors reading the stream, service-layer runtime failures) is logged and wrapped as BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED) (code 8118, message workflow.import.failed).","triggerScenarios":"POST /workflow/import where workflowExportService.importWorkflowFromYaml throws a non-BusinessException: YAML that fails to deserialize into the workflow DSL schema, a corrupted stream, or an unexpected NPE inside the import service.","commonSituations":"Hand-edited YAML with wrong indentation or missing required DSL fields; YAML exported by an older/newer platform version whose schema changed; binary or non-UTF-8 file uploaded; truncated download re-uploaded.","solutions":["Read the server log 'import workflow failed, filename=...' for the root-cause exception (usually a YAML/schema parse error).","Validate the YAML structure against a known-good export from the same platform version; re-export instead of hand-editing.","Confirm the file is valid UTF-8 text YAML, not binary or truncated.","If the schema changed between versions, migrate the DSL fields to the current format before importing."],"exampleFix":"// before\nname: my workflow\nnodes: \"not-a-list\"\n\n// after\nname: my workflow\nnodes:\n  - id: node-1\n    type: llm","handlingStrategy":"validation","validationCode":"const text = await file.text();\ntry { YAML.parse(text); } catch (e) { throw new Error('Invalid YAML: ' + e.message); }\nif (!text.includes('nodes')) throw new Error('YAML missing required workflow DSL fields');","typeGuard":null,"tryCatchPattern":"try {\n  await importWorkflowYaml(file);\n} catch (e) {\n  if (e.code === 8118) {\n    console.error('Import failed; check server log: import workflow failed, filename=...');\n    notify('YAML could not be imported — verify format and platform version');\n  } else throw e;\n}","preventionTips":["Always import YAML produced by the same platform version's export; avoid hand-editing the DSL.","Lint the YAML client-side (parse + schema check) before upload.","Ensure the file is UTF-8 text and not truncated or binary."],"tags":["import","yaml","parse-error","schema","java"],"backgroundTag":"yaml-parse-error","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"}