iflytek/astron-agent · error · BusinessException

BOT_NOT_EXISTS

BOT_NOT_EXISTS

Error message

BOT_NOT_EXISTS

What it means

BOT_NOT_EXISTS (first throw in BotOffiaccountServiceImpl.bind) fires when chatBotBaseMapper.selectById(botId) returns null, i.e. no bot exists with the given botId. The WeChat official-account bind operation refuses to proceed for an unknown bot.

Solutions

  1. Verify the botId exists in the chat bot base table (selectById) before binding
  2. Refresh the bot list in the UI and retry with a current botId
  3. Check you are calling the correct environment (staging vs prod) with a botId from that same database
  4. If the bot was deleted, recreate it or choose another bot to bind
Defensive patterns

Strategy: validation

Validate before calling

// caller pre-check
ChatBotBase bot = chatBotBaseMapper.selectById(botId);
if (bot == null) {
    // botId is stale; refresh bot list before calling bind
}

Try / catch

try {
    botOffiaccountService.bind(botId, appid, uid);
} catch (BusinessException e) {
    if (ResponseEnum.BOT_NOT_EXISTS.getCode().equals(e.getCode())) {
        // refresh the bot list and ask the user to pick a valid bot
    }
}

Prevention

When it happens

Trigger: Calling bind() with a botId that is not present in the chat bot base table — deleted bot, wrong id, or id from a different environment/database.

Common situations: Frontend holding a stale botId after the bot was deleted; cross-environment configuration (test botId in prod); copy/paste of the wrong numeric id; hard-delete cleanup jobs.

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

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/BotOffiaccountServiceImpl.java:46

 */
@Slf4j
@Service
@RequiredArgsConstructor
public class BotOffiaccountServiceImpl implements BotOffiaccountService {

    private final BotOffiaccountMapper botOffiaccountMapper;
    private final ChatBotBaseMapper chatBotBaseMapper;
    private final ApplicationEventPublisher eventPublisher;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void bind(Integer botId, String appid, String uid) {
        log.info("Starting to bind bot with WeChat official account: botId={}, appid={}, uid={}", botId, appid, uid);

        // 1. Validate bot permission
        ChatBotBase botBase = chatBotBaseMapper.selectById(botId);
        if (botBase == null) {
            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
        }

        int hasPermission = chatBotBaseMapper.checkBotPermission(botId, uid, botBase.getSpaceId());
        if (hasPermission == 0) {
            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
        }

        // 2. Check if AppID is already bound by other bot
        BotOffiaccount existingAppidBind = botOffiaccountMapper.selectOne(
                new LambdaQueryWrapper<BotOffiaccount>()
                        .eq(BotOffiaccount::getAppid, appid)
                        .eq(BotOffiaccount::getStatus, BotOffiaccountStatusEnum.BOUND.getStatus()));
        if (existingAppidBind != null && !Objects.equals(existingAppidBind.getBotId(), botId)) {
            // Unbind the old bot
            existingAppidBind.setStatus(BotOffiaccountStatusEnum.UNBOUND.getStatus());
            existingAppidBind.setUpdateTime(LocalDateTime.now());
            botOffiaccountMapper.updateById(existingAppidBind);
            log.info("WeChat AppID already bound by another bot, unbinding old bot: appid={}, oldBotId={}",

View on GitHub (pinned to 5e758547a8)