{"record":{"id":"e3e0782dc8b454ac","repo":"iflytek/astron-agent","slug":"workflow-export-failed","errorCode":"WORKFLOW_EXPORT_FAILED","errorMessage":"WORKFLOW_EXPORT_FAILED","messagePattern":"WORKFLOW_EXPORT_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java","lineNumber":344,"sourceCode":"            if (botType != null) {\n                result.setGroupName(botType.getTypeName());\n                result.setGroupNameEn(botType.getTypeNameEn());\n            }\n        }\n        result.setTemplateSource(MaasTemplate.TEMPLATE_SOURCE_EXPORTED);\n        result.setDeletable(Objects.equals(template.getCreatorUid(), uid));\n        result.setCreateTime(template.getCreateTime());\n        result.setUpdateTime(template.getUpdateTime());\n        return result;\n    }\n\n    private String exportWorkflowSnapshot(Workflow workflow) {\n        try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {\n            workflowExportService.exportWorkflowDataAsYaml(workflow, outputStream);\n            return outputStream.toString(StandardCharsets.UTF_8);\n        } catch (Exception e) {\n            log.error(\"Export workflow template snapshot failed, workflowId={}\", workflow.getId(), e);\n            throw new BusinessException(ResponseEnum.WORKFLOW_EXPORT_FAILED);\n        }\n    }\n\n    private String generateTemplateCover(String uid, Workflow workflow) {\n        String fallbackCover = workflow.getAvatarIcon();\n        try {\n            String coverUrl = CompletableFuture\n                    .supplyAsync(() -> botAIService.generateAvatar(uid, workflow.getName(), workflow.getDescription()))\n                    .orTimeout(TEMPLATE_COVER_TIMEOUT_SECONDS, TimeUnit.SECONDS)\n                    .exceptionally(ex -> null)\n                    .join();\n            if (StringUtils.isBlank(coverUrl) || AI_AVATAR_FALLBACK.equals(coverUrl)) {\n                return fallbackCover;\n            }\n            return coverUrl;\n        } catch (Exception e) {\n            log.warn(\"Generate workflow template cover failed, workflowId={}\", workflow.getId(), e);\n            return fallbackCover;","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java#L326-L362","documentation":"exportWorkflowSnapshot wraps workflowExportService.exportWorkflowDataAsYaml; any exception thrown while serializing the workflow to YAML is converted into WORKFLOW_EXPORT_FAILED. This is a catch-all conversion of an underlying export failure (I/O, NPE on graph data, unsupported node type) into a stable business error for template export paths (loadAvailableTemplate, exportTemplate).","triggerScenarios":"exportTemplate or loadAvailableTemplate invokes exportWorkflowSnapshot(workflow) and the underlying exportWorkflowDataAsYaml throws any Exception — e.g. malformed workflow graph, null node/config data, or an error writing to the ByteArrayOutputStream.","commonSituations":"A workflow saved by an older schema version contains fields the current exporter can't handle; a workflow with plugins/nodes referencing missing definitions; corrupted workflow data after a partial migration.","solutions":["Check the server log line 'Export workflow template snapshot failed, workflowId={}' for the real root-cause stack trace.","Open the workflowId in the editor and fix/save the workflow (remove broken nodes or invalid config) before exporting.","Reproduce the export with the same workflow in a debug environment to find which node/field fails serialization.","If caused by schema drift, upgrade or backfill the workflow JSON so it matches the current exporter's expected format."],"exampleFix":"// before\nString yaml = exportWorkflowSnapshot(brokenWorkflow); // throws WORKFLOW_EXPORT_FAILED\n// after\nWorkflow fixed = workflowService.getById(workflowId);\nworkflowExportService.validateExportable(fixed); // surface the real problem first\nString yaml = exportWorkflowSnapshot(fixed);","handlingStrategy":"try-catch","validationCode":"if (workflow == null || workflow.getNodes() == null || workflow.getNodes().isEmpty()) {\n    throw new IllegalStateException(\"workflow is empty or malformed; export would fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    String yaml = exportWorkflowSnapshot(workflow);\n} catch (BusinessException e) {\n    log.error(\"snapshot export failed for workflow {}\", workflow.getId(), e);\n    // inspect server log for the root cause stack trace from exportWorkflowDataAsYaml\n}","preventionTips":["Keep workflow graph data valid: delete broken nodes before exporting","Run schema backfills when workflow JSON format changes between versions","Check the server log's workflowId-scoped stack trace for the true root cause"],"tags":["yaml-export","serialization","workflow","java"],"backgroundTag":"file-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"}