iflytek/astron-agent · warning · BusinessException

WORKFLOW_NAME_EXISTED

WORKFLOW_NAME_EXISTED

Error message

WORKFLOW_NAME_EXISTED

What it means

WorkflowService throws BusinessException(WORKFLOW_NAME_EXISTED) when creating a workflow whose name already exists in the same scope. A MyBatis-Plus query checks for an existing non-deleted workflow matching the requested name within the current user's scope (uid when no spaceId, space otherwise); if found, creation is rejected. This enforces unique workflow names per user/space.

Solutions

  1. Rename the workflow in the request to a unique value within the user/space scope
  2. Query existing workflows for the target name before calling create and surface a friendly conflict to the user
  3. If the old workflow is abandoned, delete it (soft delete) and recreate
  4. Check whether spaceId vs uid scoping causes a false conflict when mixing personal and space workflows

Example fix

// before
workflowService.create(req); // name may collide
// after
if (workflowService.existsByNameAndSpace(req.getName(), spaceId)) {
    throw new UserVisibleException("Workflow name already in use");
}
workflowService.create(req);
Defensive patterns

Strategy: validation

Validate before calling

boolean nameTaken = workflowService.count(new LambdaQueryWrapper<Workflow>()
        .eq(Workflow::getName, name)
        .eq(spaceId == null, Workflow::getUid, userId)
        .eq(spaceId != null, Workflow::getSpaceId, spaceId)
        .eq(Workflow::getDeleted, false)) > 0;
if (nameTaken) throw new IllegalArgumentException("workflow name already in use");

Try / catch

try {
    workflowService.create(req);
} catch (BusinessException e) {
    if ("WORKFLOW_NAME_EXISTED".equals(e.getCode())) {
        promptUserToRename();
    } else throw e;
}

Prevention

When it happens

Trigger: Calling workflow create with createReq.getName() equal to an existing non-deleted workflow name owned by the same user (spaceId == null) or within the same space (spaceId != null). The duplicate check uses .last("limit 1") so the first match aborts the create.

Common situations: User retries a create after a prior partial failure, creates workflows with default/template names, API clients that don't dedupe names, or a name left over from a soft-deleted flow that was restored.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/5ed54a902fc44049. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java:1077

    /**
     * Create workflow: first call core "add protocol", then store locally.
     *
     * @param createReq Create request parameters
     * @param request HTTP request
     * @return Created workflow
     */
    public Workflow create(WorkflowReq createReq, HttpServletRequest request) {
        // Name duplication check (isolated by space)
        final Long spaceId = createReq.getSpaceId();
        Workflow one = getOne(
                Wrappers.lambdaQuery(Workflow.class)
                        .eq(Workflow::getName, createReq.getName())
                        .eq(spaceId == null, Workflow::getUid, UserInfoManagerHandler.getUserId())
                        .eq(spaceId != null, Workflow::getSpaceId, spaceId)
                        .eq(Workflow::getDeleted, false)
                        .last("limit 1"));
        if (one != null) {
            throw new BusinessException(ResponseEnum.WORKFLOW_NAME_EXISTED);
        }

        createReq.setAppId(commonConfig.getAppId());
        if (Boolean.TRUE.equals(createReq.getCommonUser())) {
            // Dedicated cloud commonUser logic
            createReq.setAppId(commonConfig.getAppId());
            createReq.setDomain("generalv3.5");
        }

        // Core system - add protocol, return flowId
        ApiResult<String> addResult = callProtocolAdd(createReq);
        if (addResult.code() != 0) {
            throw new BusinessException(ResponseEnum.RESPONSE_FAILED, addResult.message());
        }

        // Product side database storage
        Workflow workflow = new Workflow();
        org.springframework.beans.BeanUtils.copyProperties(createReq, workflow);

View on GitHub (pinned to 5e758547a8)