{"record":{"id":"8f0a815aeed34f4a","repo":"iflytek/astron-agent","slug":"bot-permission-validation-failed-botid-uid-spaceid","errorCode":null,"errorMessage":"Bot permission validation failed: botId={}, uid={}, spaceId={}","messagePattern":"Bot permission validation failed: botId=(.+?), uid=(.+?), spaceId=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/BotPublishServiceImpl.java","lineNumber":399,"sourceCode":"                            : 0;\n                    return new BotTimeSeriesResponseDto.TimeSeriesItem(\n                            stats.getDate().toString(), avgCount);\n                })\n                .collect(Collectors.toList());\n    }\n\n    // ==================== publishchannelmanagement ====================\n\n    @Override\n    public void updatePublishChannel(Integer botId, String uid, Long spaceId, PublishChannelEnum channel, boolean isAdd) {\n        log.info(\"Update bot publish channel: botId={}, uid={}, spaceId={}, channel={}, isAdd={}\",\n                botId, uid, spaceId, channel.getCode(), isAdd);\n\n        try {\n            // 1. Permission validation\n            int hasPermission = chatBotBaseMapper.checkBotPermission(botId, uid, spaceId);\n            if (hasPermission == 0) {\n                log.warn(\"Bot permission validation failed: botId={}, uid={}, spaceId={}\", botId, uid, spaceId);\n                return;\n            }\n\n            // 2. Query current publish channel\n            String currentChannels = getCurrentPublishChannels(botId, uid, spaceId);\n\n            // 3. Update publish channel\n            String newChannels = publishChannelService.updatePublishChannels(currentChannels, channel.getCode(), isAdd);\n\n            // 4. Update database\n            if (!Objects.equals(currentChannels, newChannels)) {\n                if (currentChannels == null) {\n                    // If no market record exists, need to create first\n                    createMarketRecordForChannel(botId, uid, spaceId, newChannels);\n                } else {\n                    // Update existing record\n                    updateMarketRecordChannels(botId, uid, spaceId, newChannels);\n                }","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/BotPublishServiceImpl.java#L381-L417","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the uid has permission via chat_bot_base (checkBotPermission) before calling the update API","Ensure spaceId matches the space where the bot and the user's membership actually live","Surface a proper permission error to the caller instead of silently returning"],"exampleFix":"// before\nif (hasPermission == 0) {\n    log.warn(\"Bot permission validation failed: botId={}, uid={}, spaceId={}\", botId, uid, spaceId);\n    return;\n}\n// after\nif (hasPermission == 0) {\n    throw new PermissionDeniedException(\"User \" + uid + \" cannot modify bot \" + botId);\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["permissions","authorization"],"backgroundTag":"permission-denied","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"}