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 publishMcp when the pre-publish permission check fails: chatBotBaseMapper.checkBotPermission returns 0, meaning no chat bot row is visible to the given user in the given space. The platform reuses this code both for 'bot does not exist' and 'caller lacks permission', so the botId may be valid but simply owned by someone else or in another space.

Solutions

  1. Verify the botId exists and belongs to the current user + spaceId before calling publishMcp (query chat_bot_base with uid/space filters).
  2. Confirm the spaceId passed to the service matches the space that owns the bot.
  3. If the bot was deleted, recreate or restore it and retry publish.
  4. Check the calling account's role/permission on the bot (owner vs viewer).

Example fix

// before
mcpService.publishMcp(new McpPublishRequestDto(99999 /* stale botId */), uid, spaceId);
// after
ChatBotBase bot = chatBotDataService.findOne(uid, 99999, spaceId);
if (bot == null) {
    throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS); // fail fast with clear context
}
mcpService.publishMcp(request, uid, spaceId);
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

boolean canPublish = bot != null && bot.getSpaceId().equals(spaceId) && bot.getUid().equals(uid);

Prevention

When it happens

Trigger: Calling POST MCP publish with a botId that does not exist, a botId belonging to another space, a bot deleted (soft-deleted), or a currentUid that is not an owner/editor of the bot.

Common situations: Stale frontend state publishing after the bot was deleted; cross-space API calls where spaceId header/token doesn't match the bot's space; typos or int/long conversion of botId; publishing from automation using a service account without bot access.

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

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/McpServiceImpl.java:54

    private final UserLangChainInfoMapper userLangChainInfoMapper;
    private final BotPublishService botPublishService;
    private final WorkflowReleaseService workflowReleaseService;
    private final UserLangChainDataService userLangChainDataService;



    @Override
    @Transactional(rollbackFor = Exception.class)
    public void publishMcp(McpPublishRequestDto request, String currentUid, Long spaceId) {
        log.info("Publish MCP: botId={}, serverName={}, uid={}, spaceId={}",
                request.getBotId(), request.getServerName(), currentUid, spaceId);

        Integer botId = request.getBotId();

        // 1. Permission check
        int hasPermission = chatBotBaseMapper.checkBotPermission(botId, currentUid, spaceId);
        if (hasPermission == 0) {
            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
        }

        // 2. Check if workflow protocol exists
        UserLangChainInfo chainInfo = userLangChainInfoMapper.selectOne(
                new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<UserLangChainInfo>()
                        .eq("bot_id", botId)
                        .orderByDesc("create_time")
                        .last("LIMIT 1"));
        if (chainInfo == null) {
            log.info("Bot workflow protocol not found: uid={}, botId={}", currentUid, botId);
            throw new BusinessException(ResponseEnum.BOT_CHAIN_SUBMIT_ERROR);
        }

        // 3. Content moderation (simplified here, should call moderation service in production)
        // TODO: Call moderation service to check text and images
        // String allText = request.getServerName() + request.getDescription() + request.getContent();

        // 4. Get version name first (without releasing yet)

View on GitHub (pinned to 5e758547a8)