{"record":{"id":"97c79ac5a5c83012","repo":"iflytek/astron-agent","slug":"workflow-template-not-exist","errorCode":"WORKFLOW_TEMPLATE_NOT_EXIST","errorMessage":"WORKFLOW_TEMPLATE_NOT_EXIST","messagePattern":"WORKFLOW_TEMPLATE_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/WorkflowService.java","lineNumber":1246,"sourceCode":"\n    /**\n     * Clone capability for certain internal workflows (with request context).\n     *\n     * @param id Workflow ID\n     * @param spaceId Space ID\n     * @param request HTTP request\n     * @return Cloned workflow\n     */\n    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)\n    public Workflow cloneForXfYun(Long id, Long spaceId, Integer flowType, Integer botId, TalkAgentConfigDto flowConfig, HttpServletRequest request) {\n        if (flowType == null) {\n            flowType = BotTypeEnum.WORKFLOW_BOT.getType();\n        }\n        String uid = RequestContextUtil.getUID();\n        log.info(\"cloneForXfYun uid = {}\", uid);\n        Workflow src = getById(id);\n        if (src == null || Boolean.TRUE.equals(src.getDeleted())) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_TEMPLATE_NOT_EXIST);\n        }\n        src.setStatus(WorkflowConst.Status.UNPUBLISHED);\n\n        // Prevent reusing old bot during cloning\n        src.setExt(null);\n\n        WorkflowReq flowReq = new WorkflowReq();\n        org.springframework.beans.BeanUtils.copyProperties(src, flowReq);\n        ApiResult<String> addResult = callProtocolAdd(flowReq);\n        if (addResult.code() != 0) {\n            throw new BusinessException(ResponseEnum.RESPONSE_FAILED, addResult.message());\n        }\n        String nFlowId = addResult.data();\n\n        BizWorkflowData data = handleDataClone(nFlowId, src.getData());\n\n        Workflow replica = new Workflow();\n        BeanUtils.copyProperties(src, replica);","sourceCodeStart":1228,"sourceCodeEnd":1264,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java#L1228-L1264","documentation":"cloneForXfYun looks up the source workflow by id with getById(id) and requires it to exist and not be soft-deleted. If src == null or src.getDeleted() == TRUE, WORKFLOW_TEMPLATE_NOT_EXIST is thrown — the clone source template is missing. This is a precondition check before any core-side clone work.","triggerScenarios":"Calling cloneForXfYun(id) where id doesn't exist in the workflow table, or the row exists but deleted=true (soft-deleted). Common when the caller caches an old workflow id or clones across spaces/environments.","commonSituations":"Stale id passed from a deleted template, cloning from another environment's data, id typo in API integration, workflow removed by another user between listing and cloning.","solutions":["Verify the source workflow id exists and deleted=false before calling cloneForXfYun","Re-fetch the workflow list to get a fresh valid id","Confirm you are querying the correct environment/database where the template lives","If the template was intentionally deleted, restore it or choose another template"],"exampleFix":"// before\nworkflowService.cloneForXfYun(id, ...); // id may be stale\n// after\nWorkflow src = workflowService.getById(id);\nif (src == null || Boolean.TRUE.equals(src.getDeleted())) {\n    throw new UserVisibleException(\"Workflow template no longer exists\");\n}\nworkflowService.cloneForXfYun(id, ...);","handlingStrategy":"validation","validationCode":"Workflow src = workflowService.getById(id);\nif (src == null || Boolean.TRUE.equals(src.getDeleted())) {\n    throw new IllegalArgumentException(\"workflow template \" + id + \" does not exist\");\n}","typeGuard":"boolean isCloneable(Workflow w) {\n    return w != null && !Boolean.TRUE.equals(w.getDeleted());\n}","tryCatchPattern":"try {\n    workflowService.cloneForXfYun(id, spaceId);\n} catch (BusinessException e) {\n    if (\"WORKFLOW_TEMPLATE_NOT_EXIST\".equals(e.getCode())) {\n        refreshWorkflowList(); // id was stale; surface not-found to user\n    } else throw e;\n}","preventionTips":["Always re-fetch workflow lists before cloning rather than caching ids","Skip soft-deleted workflows when presenting clone sources","Confirm environment/database when cloning across deployments","Clean up references to deleted templates in saved UIs"],"tags":["workflow","clone","not-found"],"backgroundTag":"entity-not-found","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"}