iflytek/astron-agent · error · BusinessException
WORKFLOW_TEMPLATE_NOT_EXIST
WORKFLOW_TEMPLATE_NOT_EXIST
Error message
WORKFLOW_TEMPLATE_NOT_EXIST
What it means
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.
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
Example fix
// before
workflowService.cloneForXfYun(id, ...); // id may be stale
// after
Workflow src = workflowService.getById(id);
if (src == null || Boolean.TRUE.equals(src.getDeleted())) {
throw new UserVisibleException("Workflow template no longer exists");
}
workflowService.cloneForXfYun(id, ...); Defensive patterns
Strategy: validation
Validate before calling
Workflow src = workflowService.getById(id);
if (src == null || Boolean.TRUE.equals(src.getDeleted())) {
throw new IllegalArgumentException("workflow template " + id + " does not exist");
} Type guard
boolean isCloneable(Workflow w) {
return w != null && !Boolean.TRUE.equals(w.getDeleted());
} Try / catch
try {
workflowService.cloneForXfYun(id, spaceId);
} catch (BusinessException e) {
if ("WORKFLOW_TEMPLATE_NOT_EXIST".equals(e.getCode())) {
refreshWorkflowList(); // id was stale; surface not-found to user
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/97c79ac5a5c83012.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java:1246
/**
* Clone capability for certain internal workflows (with request context).
*
* @param id Workflow ID
* @param spaceId Space ID
* @param request HTTP request
* @return Cloned workflow
*/
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Workflow cloneForXfYun(Long id, Long spaceId, Integer flowType, Integer botId, TalkAgentConfigDto flowConfig, HttpServletRequest request) {
if (flowType == null) {
flowType = BotTypeEnum.WORKFLOW_BOT.getType();
}
String uid = RequestContextUtil.getUID();
log.info("cloneForXfYun uid = {}", uid);
Workflow src = getById(id);
if (src == null || Boolean.TRUE.equals(src.getDeleted())) {
throw new BusinessException(ResponseEnum.WORKFLOW_TEMPLATE_NOT_EXIST);
}
src.setStatus(WorkflowConst.Status.UNPUBLISHED);
// Prevent reusing old bot during cloning
src.setExt(null);
WorkflowReq flowReq = new WorkflowReq();
org.springframework.beans.BeanUtils.copyProperties(src, flowReq);
ApiResult<String> addResult = callProtocolAdd(flowReq);
if (addResult.code() != 0) {
throw new BusinessException(ResponseEnum.RESPONSE_FAILED, addResult.message());
}
String nFlowId = addResult.data();
BizWorkflowData data = handleDataClone(nFlowId, src.getData());
Workflow replica = new Workflow();
BeanUtils.copyProperties(src, replica);View on GitHub (pinned to 5e758547a8)