{"record":{"id":"4f05e37115445b57","repo":"iflytek/astron-agent","slug":"query-current-publish-channel-failed-botid-uid-spaceid","errorCode":null,"errorMessage":"Query current publish channel failed: botId={}, uid={}, spaceId={}","messagePattern":"Query current publish channel 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":316,"sourceCode":"     * Validate bot permission\n     */\n    private void validateBotPermission(Integer botId, String uid, Long spaceId) {\n        Integer count = chatBotBaseMapper.checkBotPermission(botId, uid, spaceId);\n        if (count == null || count == 0) {\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);\n        }\n    }\n\n\n    /**\n     * Get current publish channel\n     */\n    private String getCurrentPublishChannels(Integer botId, String uid, Long spaceId) {\n        try {\n            var queryResult = chatBotMarketMapper.selectBotDetail(botId, uid, spaceId);\n            return queryResult != null ? queryResult.getPublishChannels() : null;\n        } catch (Exception e) {\n            log.warn(\"Query current publish channel failed: botId={}, uid={}, spaceId={}\", botId, uid, spaceId, e);\n            return null;\n        }\n    }\n\n    /**\n     * Create market record (for publish channel) Note: This method now delegates to event-driven\n     * architecture\n     */\n    private void createMarketRecordForChannel(Integer botId, String uid, Long spaceId, String channels) {\n        // Publish event to create market record - handled by InstructionalBotPublishListener\n        eventPublisher.publishEvent(new BotPublishStatusChangedEvent(\n                this, botId, uid, spaceId, \"PUBLISH\",\n                null, ShelfStatusEnum.OFF_SHELF.getCode(), channels));\n        log.info(\"Create market record event published: botId={}, uid={}, spaceId={}, channels={}\",\n                botId, uid, spaceId, channels);\n    }\n\n    /**","sourceCodeStart":298,"sourceCodeEnd":334,"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#L298-L334","documentation":"A warn log when querying the current publish channels for a bot fails or the market record can't be fetched; the method returns null so callers treat it as 'no channels'. Any exception from chatBotMarketMapper.selectBotDetail is caught here.","triggerScenarios":"Calling updatePublishChannel (via currentChannels) where selectBotDetail throws (DB error) or returns null because the market row doesn't exist yet for botId/uid/spaceId.","commonSituations":"Bot never published to market so no chat_bot_market row; wrong spaceId passed; DB connectivity issue; permission filtering hides the row from the user.","solutions":["Confirm a chat_bot_market record exists for the botId/uid/spaceId combination before updating channels","Verify the uid has access to the bot in the given spaceId","Check DB connectivity/exception stack trace in the log for underlying errors"],"exampleFix":"// before\nreturn queryResult != null ? queryResult.getPublishChannels() : null;\n// after\nif (queryResult == null) {\n    log.warn(\"No market record for botId={}, uid={}, spaceId={}\", botId, uid, spaceId);\n    return \"\"; // or throw RecordNotFoundException\n}\nreturn queryResult.getPublishChannels();","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["database","publish-channel","query"],"backgroundTag":"database-query-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}