iflytek/astron-agent · error · BusinessException

BOT_NOT_EXISTS

BOT_NOT_EXISTS

Error message

BOT_NOT_EXISTS

What it means

BOT_NOT_EXISTS is thrown by validateBotId when a botId parameter is null or 0, indicating no valid bot was specified. Callers (e.g. the botId endpoint) run this validation before using the id, since bot 0/null never corresponds to a real bot.

Solutions

  1. Pass a real, positive botId obtained from bot creation/list APIs
  2. Do not send botId when you mean 'no bot' — omit it or use the endpoint variant that supports absence
  3. Guard client-side: if botId is 0/null, skip the call or create the bot first
  4. Fix default initialization so unset bots don't serialize as 0

Example fix

// before
const botId = 0; await getChatList({ botId });
// after
if (!botId) throw new Error('create/select a bot first');
await getChatList({ botId: realBotId });
Defensive patterns

Strategy: validation

Validate before calling

if (!botId || botId === 0) throw new Error('a valid botId (>0) is required');

Type guard

const hasBot = (id) => typeof id === 'number' && Number.isInteger(id) && id > 0;

Try / catch

try { await api({ botId }); } catch (e) { if (e.code === 'BOT_NOT_EXISTS') { await createOrSelectBot(); } else throw e; }

Prevention

When it happens

Trigger: Calling a chat-list endpoint that takes botId without supplying botId, or explicitly passing botId=0; default/uninitialized integer field serialized as 0; query parameter omitted from the request.

Common situations: Clients initializing botId to 0 as a 'no bot' sentinel and sending it anyway; missing query param in a GET; a flow where the bot was never created so the id stayed 0.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/controller/chat/ChatListController.java:135

    private void setDefaultChatListName(ChatListCreateRequest payload) {
        if (StringUtils.isBlank(payload.getChatListName())) {
            if (payload.getShowType() != null && payload.getShowType() == 2) {
                payload.setChatListName("New Chat");
            } else {
                payload.setChatListName("New Chat Window");
            }
        }
    }

    /**
     * Validate if bot ID is valid
     *
     * @param botId Bot ID to be validated
     * @return Returns original value if botId is valid, otherwise throws exception
     */
    private Integer validateBotId(Integer botId) {
        if (botId == null || botId == 0) {
            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
        }
        return botId;
    }

    /**
     * Validate bot permissions
     *
     * @param botId Bot ID
     * @param uid User ID
     */
    private void validateBotPermissions(Integer botId, String uid) {
        ChatBotMarket chatBotMarket = chatBotDataService.findMarketBotByBotId(botId);

        if (chatBotMarket != null) {
            validateMarketBotPermissions(chatBotMarket, uid);
        } else {
            validatePrivateBotPermissions(botId, uid);
        }

View on GitHub (pinned to 5e758547a8)