{"record":{"id":"feecf704fce2dd8e","repo":"iflytek/astron-agent","slug":"workflow-not-publish","errorCode":"WORKFLOW_NOT_PUBLISH","errorMessage":"WORKFLOW_NOT_PUBLISH","messagePattern":"WORKFLOW_NOT_PUBLISH","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowAutomationService.java","lineNumber":246,"sourceCode":"        task.setScheduleType(StringUtils.defaultIfBlank(req.getScheduleType(), \"CUSTOM\"));\n        task.setTimezone(timezone);\n        task.setInputParams(inputParams);\n        task.setEnabled(Boolean.TRUE.equals(req.getEnabled()));\n        task.setNextFireTime(Boolean.TRUE.equals(req.getEnabled())\n                ? nextFireTime(req.getCronExpression(), timezone, new Date())\n                : null);\n    }\n\n    private Workflow validatePublishedWorkflow(String flowId) {\n        Workflow workflow = workflowMapper.selectOne(Wrappers.lambdaQuery(Workflow.class)\n                .eq(Workflow::getFlowId, flowId)\n                .eq(Workflow::getDeleted, false)\n                .last(\"limit 1\"));\n        if (workflow == null) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_EXIST);\n        }\n        if (!isPublished(workflow)) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_PUBLISH);\n        }\n        dataPermissionCheckTool.checkWorkflowBelong(workflow, SpaceInfoUtil.getSpaceId());\n        return workflow;\n    }\n\n    private WorkflowAutomationTask requireTask(Long id) {\n        WorkflowAutomationTask task = getById(id);\n        if (task == null || Boolean.TRUE.equals(task.getDeleted())) {\n            throw new BusinessException(ResponseEnum.DATA_NOT_EXIST);\n        }\n        Long spaceId = SpaceInfoUtil.getSpaceId();\n        String uid = UserInfoManagerHandler.getUserId();\n        boolean denied = spaceId == null\n                ? !Objects.equals(task.getUid(), uid)\n                : !Objects.equals(task.getSpaceId(), spaceId);\n        if (denied) {\n            throw new BusinessException(ResponseEnum.EXCEED_AUTHORITY);\n        }","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowAutomationService.java#L228-L264","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Publish the workflow (via the console publish API) before creating or running the automation task.","Re-publish the latest version if it was unpublished or rolled back.","Disable/delete automation tasks pointing at workflows you intend to keep unpublished."],"exampleFix":"// before\nautomationService.runTask(taskId); // workflow is draft\n// after\nworkflowService.publish(flowId); // bring to published state first\nautomationService.runTask(taskId);","handlingStrategy":"validation","validationCode":"const wf = await workflowApi.get(flowId);\nif (wf && wf.status !== 'PUBLISHED') throw new Error('workflow must be published before automation');","typeGuard":"function isPublished(w) { return w != null && w.status === 'PUBLISHED'; }","tryCatchPattern":"try { automationService.createTask(flowId, cron, enabled); } catch (BusinessException e) { if (e.getCode() == WORKFLOW_NOT_PUBLISH) { promptUserToPublish(); } throw e; }","preventionTips":["Gate task creation UI on workflow publish status.","Re-validate publish state when a task is executed, not just when created.","Notify task owners when the referenced workflow is unpublished."],"tags":["workflow","state","publish"],"backgroundTag":"invalid-state-transition","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"}