iflytek/astron-agent · error · BusinessException

DUPLICATE_BOT_NAME

DUPLICATE_BOT_NAME

Error message

DUPLICATE_BOT_NAME

What it means

BusinessException with code DUPLICATE_BOT_NAME thrown by validateBotCreation when chatBotDataService.checkRepeatBotName reports the uid already owns a bot with the given name in the target space. Bot names must be unique per user/space, so creation is rejected before any persistence happens.

Solutions

  1. Rename the bot to a unique name before calling the create API.
  2. Query the user's existing bot list first and pick a non-conflicting name.
  3. If the duplicate is a leftover from a failed earlier attempt, delete the old bot or reuse it instead of creating a new one.
  4. If the check is a false positive (e.g. deleted-but-not-purged bot), investigate soft-deleted records in chatBotDataService.

Example fix

// before
await createBot({ botName: 'My Assistant', ... });
// after
const existing = await listBots();
if (existing.some(b => b.botName === 'My Assistant')) {
  throw new Error('Name in use; choose another');
}
await createBot({ botName: 'My Assistant v2', ... });
Defensive patterns

Strategy: validation

Validate before calling

const names = (await listBots()).map(b => b.botName);
if (names.includes(newName)) throw new Error('Bot name already in use');

Try / catch

try { await createBot(form); } catch (e) { if (e.code === 'DUPLICATE_BOT_NAME') { promptUserToRename(); } else throw e; }

Prevention

When it happens

Trigger: Calling insertWorkflowBot or insertBotBasicInfo with a botName that already exists for the same uid (and same spaceId, when provided) — including case/whitespace variants if the DB check is not normalized.

Common situations: Users re-submitting a create form after a perceived failure when the bot was actually created; copying a bot and keeping the default name; automation/scripts that recreate bots idempotently without checking existing names.

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/f3ff1e268e79b2e5. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/commons/src/main/java/com/iflytek/astron/console/commons/service/bot/impl/BotServiceImpl.java:321

                throw new IllegalStateException("Distributed lock acquisition timeout, please try again later");
            }
            return operation.get();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException("Thread interrupted while acquiring lock", e);
        } catch (Exception e) {
            log.error("Operation failed with lock: {}", lockKey, e);
            throw e;
        } finally {
            if (lock.isHeldByCurrentThread()) {
                lock.unlock();
            }
        }
    }

    private void validateBotCreation(String uid, String botName, Long spaceId) {
        if (chatBotDataService.checkRepeatBotName(uid, null, botName, spaceId)) {
            throw new BusinessException(ResponseEnum.DUPLICATE_BOT_NAME);
        }

        Long count = (spaceId == null) ? chatBotDataService.countBotsByUid(uid) : chatBotDataService.countBotsByUid(uid, spaceId);

        if (count.intValue() > 100) {
            throw new BusinessException(ResponseEnum.TOO_MANY_BOTS);
        }
    }

    private void validateBotNameForUpdate(String uid, String botName, Long spaceId) {
        if (chatBotDataService.checkRepeatBotName(uid, null, botName, spaceId)) {
            throw new BusinessException(ResponseEnum.DUPLICATE_BOT_NAME);
        }
    }

    private void validateBotNameForUpdate(String uid, String botName, Integer botId, Long spaceId) {
        if (chatBotDataService.checkRepeatBotName(uid, botId, botName, spaceId)) {
            throw new BusinessException(ResponseEnum.DUPLICATE_BOT_NAME);

View on GitHub (pinned to 5e758547a8)