iflytek/astron-agent · warning · BusinessException

BOT_BELONG_ERROR

BOT_BELONG_ERROR

Error message

BOT_BELONG_ERROR

What it means

BotFavoriteServiceImpl.create rejects favoriting a bot that is neither publicly available nor owned by the requesting user. If the market record exists but its botStatus is not 1/2/4 (shelved states) and the requester is not the author, it throws BusinessException with code BOT_BELONG_ERROR — an access-permission rejection.

Solutions

  1. Check the bot's botStatus in chat_bot_market; only favorite bots with status 1, 2, or 4 (or your own bots)
  2. Refresh the frontend bot list so delisted bots are no longer favoritable
  3. Verify the authenticated uid matches the intended user (token/session mismatch can cause false denial)
  4. Catch BusinessException with code BOT_BELONG_ERROR and show a friendly 'bot unavailable' message

Example fix

// before
botFavoriteService.create(uid, botId); // bot is off-shelf and not owned by uid
// after
ChatBotMarket m = marketMapper.selectOne(new QueryWrapper<ChatBotMarket>().eq("bot_id", botId));
if (m == null || (m.getBotStatus() != 1 && m.getBotStatus() != 2 && m.getBotStatus() != 4
        && !Objects.equals(m.getUid(), uid))) {
    throw new BusinessException(ResponseEnum.BOT_BELONG_ERROR);
}
botFavoriteService.create(uid, botId);
Defensive patterns

Strategy: try-catch

Validate before calling

ChatBotMarket m = marketMapper.selectOne(new QueryWrapper<ChatBotMarket>().eq("bot_id", botId)); boolean favoriteAllowed = m != null && (m.getBotStatus() == 1 || m.getBotStatus() == 2 || m.getBotStatus() == 4 || Objects.equals(m.getUid(), uid));

Try / catch

try { botFavoriteService.create(uid, botId); } catch (BusinessException e) { if (ResponseEnum.BOT_BELONG_ERROR.getCode().equals(e.getCode())) return conflict("Bot not available for favoriting"); throw e; }

Prevention

When it happens

Trigger: Calling create(uid, botId) where the bot is off-shelf (botStatus 0/3/etc.) and uid differs from the bot author's uid in chat_bot_market.

Common situations: Users trying to favorite a bot that was taken off the market; stale frontend pages listing delisted bots; bots restricted to their authors; wrong uid passed from the auth context.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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

Appendix: source

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

        if (uid.equals(market.getUid())) {
            market.setMine(true);
        }
        market.setIsFavorite(1);
        market.setUid(null); // Hide sensitive data

        if ("en".equals(langCode) && market.getBotNameEn() != null) {
            market.setBotName(market.getBotNameEn());
        }
    }

    @Override
    public void create(String uid, Integer botId) {
        QueryWrapper<ChatBotMarket> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("bot_id", botId);
        ChatBotMarket chatBotMarket = chatBotMarketMapper.selectOne(queryWrapper);
        // Bot not on shelf, and current uid is not equal to author uid, no permission to access
        if (chatBotMarket != null && (chatBotMarket.getBotStatus() != 1 && chatBotMarket.getBotStatus() != 2 && chatBotMarket.getBotStatus() != 4 && !Objects.equals(chatBotMarket.getUid(), uid))) {
            throw new BusinessException(ResponseEnum.BOT_BELONG_ERROR);
        }
        if (chatBotMarket == null) {
            ChatBotBase botBase = chatBotBaseMapper.selectOne(Wrappers.lambdaQuery(ChatBotBase.class).eq(ChatBotBase::getId, botId).eq(ChatBotBase::getUid, uid));
            if (botBase == null) {
                throw new BusinessException(ResponseEnum.BOT_BELONG_ERROR);
            }
        }

        BotFavorite botFavorite = botFavoriteMapper.selectOne(Wrappers.lambdaQuery(BotFavorite.class).eq(BotFavorite::getUid, uid).eq(BotFavorite::getBotId, botId));
        if (botFavorite != null) {
            log.error("[Assistant Favorite] User {} has already favorited assistant {}", uid, botId);
            return;
        }

        BotFavorite entity = BotFavorite.builder().uid(uid).botId(botId).createTime(LocalDateTime.now()).updateTime(LocalDateTime.now()).build();
        botFavoriteMapper.insert(entity);
    }

View on GitHub (pinned to 5e758547a8)