iflytek/astron-agent · error · BusinessException

WORKFLOW_EXPORT_FAILED

WORKFLOW_EXPORT_FAILED

Error message

WORKFLOW_EXPORT_FAILED

What it means

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).

Solutions

  1. Check the server log line 'Export workflow template snapshot failed, workflowId={}' for the real root-cause stack trace.
  2. Open the workflowId in the editor and fix/save the workflow (remove broken nodes or invalid config) before exporting.
  3. Reproduce the export with the same workflow in a debug environment to find which node/field fails serialization.
  4. If caused by schema drift, upgrade or backfill the workflow JSON so it matches the current exporter's expected format.

Example fix

// before
String yaml = exportWorkflowSnapshot(brokenWorkflow); // throws WORKFLOW_EXPORT_FAILED
// after
Workflow fixed = workflowService.getById(workflowId);
workflowExportService.validateExportable(fixed); // surface the real problem first
String yaml = exportWorkflowSnapshot(fixed);
Defensive patterns

Strategy: try-catch

Validate before calling

if (workflow == null || workflow.getNodes() == null || workflow.getNodes().isEmpty()) {
    throw new IllegalStateException("workflow is empty or malformed; export would fail");
}

Try / catch

try {
    String yaml = exportWorkflowSnapshot(workflow);
} catch (BusinessException e) {
    log.error("snapshot export failed for workflow {}", workflow.getId(), e);
    // inspect server log for the root cause stack trace from exportWorkflowDataAsYaml
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/e3e0782dc8b454ac. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java:344

            if (botType != null) {
                result.setGroupName(botType.getTypeName());
                result.setGroupNameEn(botType.getTypeNameEn());
            }
        }
        result.setTemplateSource(MaasTemplate.TEMPLATE_SOURCE_EXPORTED);
        result.setDeletable(Objects.equals(template.getCreatorUid(), uid));
        result.setCreateTime(template.getCreateTime());
        result.setUpdateTime(template.getUpdateTime());
        return result;
    }

    private String exportWorkflowSnapshot(Workflow workflow) {
        try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
            workflowExportService.exportWorkflowDataAsYaml(workflow, outputStream);
            return outputStream.toString(StandardCharsets.UTF_8);
        } catch (Exception e) {
            log.error("Export workflow template snapshot failed, workflowId={}", workflow.getId(), e);
            throw new BusinessException(ResponseEnum.WORKFLOW_EXPORT_FAILED);
        }
    }

    private String generateTemplateCover(String uid, Workflow workflow) {
        String fallbackCover = workflow.getAvatarIcon();
        try {
            String coverUrl = CompletableFuture
                    .supplyAsync(() -> botAIService.generateAvatar(uid, workflow.getName(), workflow.getDescription()))
                    .orTimeout(TEMPLATE_COVER_TIMEOUT_SECONDS, TimeUnit.SECONDS)
                    .exceptionally(ex -> null)
                    .join();
            if (StringUtils.isBlank(coverUrl) || AI_AVATAR_FALLBACK.equals(coverUrl)) {
                return fallbackCover;
            }
            return coverUrl;
        } catch (Exception e) {
            log.warn("Generate workflow template cover failed, workflowId={}", workflow.getId(), e);
            return fallbackCover;

View on GitHub (pinned to 5e758547a8)