iflytek/astron-agent · error · BusinessException

WORKFLOW_NOT_PUBLISH

WORKFLOW_NOT_PUBLISH

Error message

WORKFLOW_NOT_PUBLISH

What it means

After the workflow is found, validatePublishedWorkflow checks isPublished(workflow) and throws WORKFLOW_NOT_PUBLISH if the workflow exists but is not in a published state. Automation tasks may only target published workflows.

Solutions

  1. Publish the workflow (via the console publish API) before creating or running the automation task.
  2. Re-publish the latest version if it was unpublished or rolled back.
  3. Disable/delete automation tasks pointing at workflows you intend to keep unpublished.

Example fix

// before
automationService.runTask(taskId); // workflow is draft
// after
workflowService.publish(flowId); // bring to published state first
automationService.runTask(taskId);
Defensive patterns

Strategy: validation

Validate before calling

const wf = await workflowApi.get(flowId);
if (wf && wf.status !== 'PUBLISHED') throw new Error('workflow must be published before automation');

Type guard

function isPublished(w) { return w != null && w.status === 'PUBLISHED'; }

Try / catch

try { automationService.createTask(flowId, cron, enabled); } catch (BusinessException e) { if (e.getCode() == WORKFLOW_NOT_PUBLISH) { promptUserToPublish(); } throw e; }

Prevention

When it happens

Trigger: Creating or running an automation task against a workflow that is still in draft, has unpublished edits, or was unpublished (taken offline) after the task was created.

Common situations: A teammate unpublished or reverted the workflow while a scheduled task referenced it; a task created against a freshly drafted flow before its first publish; an expired/rolled-back publish version.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowAutomationService.java:246

        task.setScheduleType(StringUtils.defaultIfBlank(req.getScheduleType(), "CUSTOM"));
        task.setTimezone(timezone);
        task.setInputParams(inputParams);
        task.setEnabled(Boolean.TRUE.equals(req.getEnabled()));
        task.setNextFireTime(Boolean.TRUE.equals(req.getEnabled())
                ? nextFireTime(req.getCronExpression(), timezone, new Date())
                : null);
    }

    private Workflow validatePublishedWorkflow(String flowId) {
        Workflow workflow = workflowMapper.selectOne(Wrappers.lambdaQuery(Workflow.class)
                .eq(Workflow::getFlowId, flowId)
                .eq(Workflow::getDeleted, false)
                .last("limit 1"));
        if (workflow == null) {
            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_EXIST);
        }
        if (!isPublished(workflow)) {
            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_PUBLISH);
        }
        dataPermissionCheckTool.checkWorkflowBelong(workflow, SpaceInfoUtil.getSpaceId());
        return workflow;
    }

    private WorkflowAutomationTask requireTask(Long id) {
        WorkflowAutomationTask task = getById(id);
        if (task == null || Boolean.TRUE.equals(task.getDeleted())) {
            throw new BusinessException(ResponseEnum.DATA_NOT_EXIST);
        }
        Long spaceId = SpaceInfoUtil.getSpaceId();
        String uid = UserInfoManagerHandler.getUserId();
        boolean denied = spaceId == null
                ? !Objects.equals(task.getUid(), uid)
                : !Objects.equals(task.getSpaceId(), spaceId);
        if (denied) {
            throw new BusinessException(ResponseEnum.EXCEED_AUTHORITY);
        }

View on GitHub (pinned to 5e758547a8)