{"record":{"id":"4392b1fd0b5fba72","repo":"iflytek/astron-agent","slug":"workflow-version-publish-failed-4392b1","errorCode":"WORKFLOW_VERSION_PUBLISH_FAILED","errorMessage":"WORKFLOW_VERSION_PUBLISH_FAILED","messagePattern":"WORKFLOW_VERSION_PUBLISH_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/WorkflowReleaseServiceImpl.java","lineNumber":108,"sourceCode":"            }\n\n            // 5. Sync to API system directly (no approval needed)\n            String appId;\n            if (ReleaseTypeEnum.MARKET.name().equals(publishType)) {\n                appId = maasAppId;\n            } else {\n                appId = getAppIdByBotId(botId);\n            }\n            syncToApiSystem(botId, flowId, versionName, appId);\n\n            // 6. Update audit result to success\n            if (!updateAuditResult(\n                    response.getWorkflowVersionId(),\n                    flowId,\n                    WorkflowConst.PublishResult.SUCCESS,\n                    uid,\n                    spaceId)) {\n                throw new BusinessException(ResponseEnum.WORKFLOW_VERSION_PUBLISH_FAILED);\n            }\n\n            log.info(\"Workflow bot publish and sync successful: botId={}, versionId={}, versionName={}\",\n                    botId, response.getWorkflowVersionId(), response.getWorkflowVersionName());\n\n            return response;\n\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            log.error(\"Workflow bot publish failed: botId={}, uid={}, spaceId={}\", botId, uid, spaceId, e);\n            return createErrorResponse(\"Publish failed: \" + e.getMessage());\n        }\n    }\n\n    /**\n     * Get next version name for workflow release Simplified to match old project logic exactly - no\n     * fallback","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java#L90-L126","documentation":"publishWorkflow throws WORKFLOW_VERSION_PUBLISH_FAILED when the post-publish audit-result sync (updateAuditResult) returns false after the bot publish call succeeded. It signals that although publishing was attempted, recording the SUCCESS audit state failed, so the publish cannot be reported as complete.","triggerScenarios":"During publishWorkflow, the remote publish response comes back, but updateAuditResult(response.getWorkflowVersionId(), flowId, WorkflowConst.PublishResult.SUCCESS, uid, spaceId) returns false — typically because the version row identified by workflowVersionId/flowId no longer exists, was concurrently modified, or the update affected 0 rows.","commonSituations":"The workflow version was deleted by another user mid-publish; flowId/workflowVersionId mismatch after a re-publish; DB constraint or optimistic-lock failure during the audit update; publishing a stale draft that was edited concurrently in another tab.","solutions":["Check whether the workflow version row for response.getWorkflowVersionId() exists and matches flowId in the DB.","Retry publishWorkflow — a transient concurrent update can make updateAuditResult affect 0 rows.","Refresh the workflow in the editor to get a fresh flowId/version and re-publish.","Add logging inside updateAuditResult to distinguish 'row not found' from 'update failed' and fix the mismatched identifiers."],"exampleFix":"// before\nWorkflowReleaseService.publishWorkflow(staleFlowId, ...); // version already replaced\n// after\nworkflowService.refreshDraft(flowId);           // reload latest version ids\nreleaseService.publishWorkflow(latestFlowId, ...);","handlingStrategy":"retry","validationCode":"WorkflowVersion v = versionMapper.selectById(response.getWorkflowVersionId());\nif (v == null || !Objects.equals(v.getFlowId(), flowId)) {\n    throw new IllegalStateException(\"version/flow mismatch before audit update; refresh and re-publish\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    releaseService.publishWorkflow(botId, flowId, uid, spaceId);\n} catch (BusinessException e) {\n    if (\"WORKFLOW_VERSION_PUBLISH_FAILED\".equals(e.getCode())) {\n        retryOnceAfterReload(flowId); // reload latest version ids and re-publish\n    }\n}","preventionTips":["Avoid concurrent edits/publishes of the same workflow (lock or single-editor guard)","Reload the workflow draft to get fresh flowId/version before publishing","Log updateAuditResult's affected-row count to distinguish not-found from write failure"],"tags":["workflow-publish","audit","state-sync","java"],"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-19T12:17:13.211Z"}