iflytek/astron-agent · error · BusinessException

WORKFLOW_IMPORT_FAILED

WORKFLOW_IMPORT_FAILED

Error message

WORKFLOW_IMPORT_FAILED

What it means

Thrown when workflowExportService.importWorkflowFromYaml returns a non-zero code or its data is not a Workflow instance. The template snapshot YAML failed to import into the workflow engine, so creation from the exported template aborts.

Solutions

  1. Log importResult.code() and message to get the importer's concrete failure reason
  2. Validate the snapshot YAML against the current workflow schema; re-export the template if it is from an old version
  3. Ensure UTF-8 is used consistently when the YAML was stored/retrieved (getBytes(StandardCharsets.UTF_8))
  4. Confirm importWorkflowFromYaml still returns ApiResult<Workflow>; adjust the unwrapping if the response shape changed

Example fix

// before
if (importResult.code() != 0 || !(importResult.data() instanceof Workflow importedWorkflow)) {
    throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
}
// after
if (importResult.code() != 0 || !(importResult.data() instanceof Workflow importedWorkflow)) {
    log.error("YAML import failed, templateId={}, code={}, msg={}", templateId, importResult.code(), importResult.message());
    throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate snapshot shape before import
if (template.getSnapshotYaml() == null || !template.getSnapshotYaml().contains("nodes")) {
    return ApiResult.fail("snapshot YAML malformed");
}

Type guard

Object data = importResult.data();
if (importResult.code() == 0 && data instanceof Workflow wf) { /* proceed with wf */ }

Try / catch

try {
    botMaasService.createFromTemplate(uid, req, httpRequest);
} catch (BusinessException e) {
    if (ResponseEnum.WORKFLOW_IMPORT_FAILED.getCode().equals(e.getCode())) {
        // ask user to re-export the template; log importResult.code()/message server-side
    }
    throw e;
}

Prevention

When it happens

Trigger: createFromExportedTemplate invoking importWorkflowFromYaml(new ByteArrayInputStream(snapshotYaml bytes), request) where the import service returns code != 0 or an unexpected data payload (not Workflow).

Common situations: Snapshot YAML produced by an older exporter version that current import logic rejects, YAML corrupted by charset/encoding issues, referenced nodes/plugins missing in the target environment, or import API contract change (data wrapped differently so the instanceof check fails).

Related errors


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

Appendix: source

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

            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);
        }

        ExportedWorkflowTemplate template = loadAvailableTemplate(uid, templateId);
        if (template == null || StringUtils.isBlank(template.getSnapshotYaml())) {
            log.warn("Create workflow from exported template failed, templateId={}, uid={}, spaceId={}, templateFound={}, snapshotBlank={}",
                    templateId,
                    uid,
                    SpaceInfoUtil.getSpaceId(),
                    template != null,
                    template == null || StringUtils.isBlank(template.getSnapshotYaml()));
            throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);
        }

        ApiResult<?> importResult = workflowExportService.importWorkflowFromYaml(
                new ByteArrayInputStream(template.getSnapshotYaml().getBytes(StandardCharsets.UTF_8)),
                request);
        if (importResult.code() != 0 || !(importResult.data() instanceof Workflow importedWorkflow)) {
            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);
        }

        JSONObject ext = JSONObject.parseObject(importedWorkflow.getExt());
        BotInfoDto botInfoDto = new BotInfoDto();
        botInfoDto.setBotId(ext == null ? null : ext.getInteger("botId"));
        botInfoDto.setBotName(importedWorkflow.getName());
        botInfoDto.setBotDesc(importedWorkflow.getDescription());
        botInfoDto.setAvatar(importedWorkflow.getAvatarIcon());
        botInfoDto.setVersion(BotVersionEnum.WORKFLOW.getVersion());
        botInfoDto.setFlowId(importedWorkflow.getId());
        botInfoDto.setMaasId(importedWorkflow.getId());
        return botInfoDto;
    }

    private ExportedWorkflowTemplate loadAvailableTemplate(String uid, Long templateId) {
        ExportedWorkflowTemplate template = exportedWorkflowTemplateMapper.selectById(templateId);
        if (template == null || !Objects.equals(template.getIsDelete(), (byte) 0)) {
            log.warn("Exported workflow template unavailable, templateId={}, uid={}, templateFound={}, isDelete={}",

View on GitHub (pinned to 5e758547a8)