{"record":{"id":"7f48c920ac7d2d2b","repo":"iflytek/astron-agent","slug":"8110-workflow-not-exist","errorCode":"8110","errorMessage":"workflow.not.exist","messagePattern":"workflow\\.not\\.exist","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/VersionService.java","lineNumber":289,"sourceCode":"            workflowVersionMapper.insert(workflowVersion);\n\n            return ApiResult.success(new JSONObject()\n                    .fluentPut(\"workflowVersionId\", workflowVersion.getId())\n                    .fluentPut(\"workflowVersionName\", createDto.getName()));\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_VERSION_ADD_FAILED);\n        }\n        //\n    }\n\n    private Workflow requireWorkflow(String flowId) {\n        Workflow workflow = workflowMapper.selectOne(Wrappers.lambdaQuery(Workflow.class)\n                .eq(Workflow::getFlowId, flowId)\n                .eq(Workflow::getDeleted, false));\n        if (workflow == null || Boolean.TRUE.equals(workflow.getDeleted())) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_EXIST);\n        }\n        return workflow;\n    }\n\n    /**\n     * Update isVersion flag for all versions of a specific flowId. Sets all versions' isVersion to 2\n     * (inactive) for the given flowId.\n     *\n     * @param flowId Flow ID to update versions for\n     */\n    public void updateIsVersionForFlowId(String flowId) {\n        // Build update conditions\n        LambdaUpdateWrapper<WorkflowVersion> updateWrapper = new LambdaUpdateWrapper<>();\n        updateWrapper.eq(WorkflowVersion::getFlowId, flowId)\n                .eq(WorkflowVersion::getIsVersion, 1)\n                .set(WorkflowVersion::getIsVersion, 2);\n        // Execute update\n        workflowVersionMapper.update(null, updateWrapper);","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/VersionService.java#L271-L307","documentation":"Thrown by VersionService.requireWorkflow when no live (deleted=false) workflow row matches the given flowId. Signals the workflow referenced by the request does not exist or has been logically deleted (code 8110).","triggerScenarios":"Any service method that resolves a workflow by flowId (e.g. version operations calling requireWorkflow) with a flowId that is absent from the workflow table or whose row has deleted=true.","commonSituations":"Caller passes a stale flowId after the workflow was deleted; typo'd or fabricated flowId from client; cross-space request where the workflow belongs to another space; race with a concurrent logical delete.","solutions":["Confirm the flowId exists: SELECT * FROM workflow WHERE flow_id = ? AND deleted = 0","Re-fetch the workflow list from the UI/API instead of caching an old flowId","Check you are operating in the correct space/tenant (SpaceInfoUtil space context)","If the workflow was deleted, recreate it or restore it rather than retrying version operations"],"exampleFix":"// before\nversionService.createVersion(dtoWithStaleFlowId);\n// after\nWorkflow wf = workflowMapper.selectOne(new LambdaQueryWrapper<Workflow>()\n        .eq(Workflow::getFlowId, flowId).eq(Workflow::getDeleted, false));\nif (wf == null) { throw new BusinessException(ResponseEnum.WORKFLOW_NOT_EXIST); }\nversionService.createVersion(dto);","handlingStrategy":"validation","validationCode":"Workflow wf = workflowMapper.selectOne(new LambdaQueryWrapper<Workflow>()\n        .eq(Workflow::getFlowId, flowId).eq(Workflow::getDeleted, false));\nboolean exists = wf != null;","typeGuard":"boolean workflowExists(String flowId) {\n    return workflowMapper.selectCount(new LambdaQueryWrapper<Workflow>()\n        .eq(Workflow::getFlowId, flowId).eq(Workflow::getDeleted, false)) > 0;\n}","tryCatchPattern":"try {\n    return serviceMethodRequiringWorkflow(flowId);\n} catch (BusinessException e) {\n    if (\"workflow.not.exist\".equals(e.getMessage())) { return notFoundResponse(flowId); }\n    throw e;\n}","preventionTips":["Always resolve flowId from a fresh workflow-list API call, never cached values","Include the space context so queries hit the right tenant","Handle workflow deletion events in the client by invalidating dependent state","Use deleted=0 filters consistently in all direct DB checks"],"tags":["java","workflow","not-found"],"backgroundTag":"record-not-found","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"}