iflytek/astron-agent · warning

Bot permission validation failed: botId=

Error message

Bot permission validation failed: botId={}, uid={}, spaceId={}

What it means

updatePublishChannel logs 'Bot permission validation failed: botId={}, uid={}, spaceId={}' when the permission check rejects the caller before mutating the bot's publish-channel set. The placeholders identify which bot/space/user combination was denied, typically because the user lacks write access to the bot in that space.

Solutions

  1. Verify the uid has permission via chat_bot_base (checkBotPermission) before calling the update API
  2. Ensure spaceId matches the space where the bot and the user's membership actually live
  3. Surface a proper permission error to the caller instead of silently returning

Example fix

// before
if (hasPermission == 0) {
    log.warn("Bot permission validation failed: botId={}, uid={}, spaceId={}", botId, uid, spaceId);
    return;
}
// after
if (hasPermission == 0) {
    throw new PermissionDeniedException("User " + uid + " cannot modify bot " + botId);
}
Defensive patterns

Strategy: validation

When it happens

Trigger: Calling updatePublishChannel with a uid that is not owner/editor of the bot, a wrong spaceId, or a botId that doesn't exist in that space.

Common situations: User operating on a bot in a space they don't belong to; bot transferred to another owner; API clients caching stale botId/spaceId pairs.

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

Appendix: source

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

                            : 0;
                    return new BotTimeSeriesResponseDto.TimeSeriesItem(
                            stats.getDate().toString(), avgCount);
                })
                .collect(Collectors.toList());
    }

    // ==================== publishchannelmanagement ====================

    @Override
    public void updatePublishChannel(Integer botId, String uid, Long spaceId, PublishChannelEnum channel, boolean isAdd) {
        log.info("Update bot publish channel: botId={}, uid={}, spaceId={}, channel={}, isAdd={}",
                botId, uid, spaceId, channel.getCode(), isAdd);

        try {
            // 1. Permission validation
            int hasPermission = chatBotBaseMapper.checkBotPermission(botId, uid, spaceId);
            if (hasPermission == 0) {
                log.warn("Bot permission validation failed: botId={}, uid={}, spaceId={}", botId, uid, spaceId);
                return;
            }

            // 2. Query current publish channel
            String currentChannels = getCurrentPublishChannels(botId, uid, spaceId);

            // 3. Update publish channel
            String newChannels = publishChannelService.updatePublishChannels(currentChannels, channel.getCode(), isAdd);

            // 4. Update database
            if (!Objects.equals(currentChannels, newChannels)) {
                if (currentChannels == null) {
                    // If no market record exists, need to create first
                    createMarketRecordForChannel(botId, uid, spaceId, newChannels);
                } else {
                    // Update existing record
                    updateMarketRecordChannels(botId, uid, spaceId, newChannels);
                }

View on GitHub (pinned to 5e758547a8)