{"record":{"id":"d19c6628c80c24d6","repo":"iflytek/astron-agent","slug":"bot-not-exists-d19c66","errorCode":"BOT_NOT_EXISTS","errorMessage":"BOT_NOT_EXISTS","messagePattern":"BOT_NOT_EXISTS","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/BotOffiaccountServiceImpl.java","lineNumber":46,"sourceCode":" */\n@Slf4j\n@Service\n@RequiredArgsConstructor\npublic class BotOffiaccountServiceImpl implements BotOffiaccountService {\n\n    private final BotOffiaccountMapper botOffiaccountMapper;\n    private final ChatBotBaseMapper chatBotBaseMapper;\n    private final ApplicationEventPublisher eventPublisher;\n\n    @Override\n    @Transactional(rollbackFor = Exception.class)\n    public void bind(Integer botId, String appid, String uid) {\n        log.info(\"Starting to bind bot with WeChat official account: botId={}, appid={}, uid={}\", botId, appid, uid);\n\n        // 1. Validate bot permission\n        ChatBotBase botBase = chatBotBaseMapper.selectById(botId);\n        if (botBase == null) {\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);\n        }\n\n        int hasPermission = chatBotBaseMapper.checkBotPermission(botId, uid, botBase.getSpaceId());\n        if (hasPermission == 0) {\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);\n        }\n\n        // 2. Check if AppID is already bound by other bot\n        BotOffiaccount existingAppidBind = botOffiaccountMapper.selectOne(\n                new LambdaQueryWrapper<BotOffiaccount>()\n                        .eq(BotOffiaccount::getAppid, appid)\n                        .eq(BotOffiaccount::getStatus, BotOffiaccountStatusEnum.BOUND.getStatus()));\n        if (existingAppidBind != null && !Objects.equals(existingAppidBind.getBotId(), botId)) {\n            // Unbind the old bot\n            existingAppidBind.setStatus(BotOffiaccountStatusEnum.UNBOUND.getStatus());\n            existingAppidBind.setUpdateTime(LocalDateTime.now());\n            botOffiaccountMapper.updateById(existingAppidBind);\n            log.info(\"WeChat AppID already bound by another bot, unbinding old bot: appid={}, oldBotId={}\",","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/wechat/impl/BotOffiaccountServiceImpl.java#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the botId exists in the chat bot base table (selectById) before binding","Refresh the bot list in the UI and retry with a current botId","Check you are calling the correct environment (staging vs prod) with a botId from that same database","If the bot was deleted, recreate it or choose another bot to bind"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// caller pre-check\nChatBotBase bot = chatBotBaseMapper.selectById(botId);\nif (bot == null) {\n    // botId is stale; refresh bot list before calling bind\n}","typeGuard":null,"tryCatchPattern":"try {\n    botOffiaccountService.bind(botId, appid, uid);\n} catch (BusinessException e) {\n    if (ResponseEnum.BOT_NOT_EXISTS.getCode().equals(e.getCode())) {\n        // refresh the bot list and ask the user to pick a valid bot\n    }\n}","preventionTips":["Refresh cached bot lists after deletions","Never hardcode botIds in configs; resolve them per environment","Validate botId against the same database/environment you call"],"tags":["java","wechat","bot-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}