{"record":{"id":"4e7169dcaef22022","repo":"iflytek/astron-agent","slug":"insufficient-permissions","errorCode":"INSUFFICIENT_PERMISSIONS","errorMessage":"INSUFFICIENT_PERMISSIONS","messagePattern":"INSUFFICIENT_PERMISSIONS","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentdebug/impl/AgentDebugServiceImpl.java","lineNumber":155,"sourceCode":"        update.setIsDelete(1);\n        update.setUpdateTime(LocalDateTime.now());\n        LambdaUpdateWrapper<AgentDebugSession> updateWrapper = Wrappers.lambdaUpdate(AgentDebugSession.class)\n                .eq(AgentDebugSession::getBotId, botId)\n                .eq(AgentDebugSession::getUid, uid)\n                .eq(AgentDebugSession::getIsDelete, 0);\n        addSpaceCondition(updateWrapper, spaceId);\n        sessionMapper.update(update, updateWrapper);\n    }\n\n    private void validateUser(String uid) {\n        if (StringUtils.isBlank(uid)) {\n            throw new BusinessException(ResponseEnum.UNAUTHORIZED);\n        }\n    }\n\n    private void checkBotPermission(String uid, Long spaceId, Integer botId) {\n        if (botId == null || chatBotBaseMapper.checkBotPermission(botId, uid, spaceId) <= 0) {\n            throw new BusinessException(ResponseEnum.INSUFFICIENT_PERMISSIONS);\n        }\n    }\n\n    private AgentDebugSession findAccessibleSession(String uid, Long spaceId, String sessionId) {\n        AgentDebugSession session = findSession(uid, sessionId);\n        if (!isSameSpace(session.getSpaceId(), spaceId)) {\n            throw new BusinessException(ResponseEnum.DATA_NOT_FOUND);\n        }\n        checkBotPermission(uid, spaceId, session.getBotId());\n        return session;\n    }\n\n    private boolean isSameSpace(Long sessionSpaceId, Long currentSpaceId) {\n        if (sessionSpaceId == null || currentSpaceId == null) {\n            return sessionSpaceId == null && currentSpaceId == null;\n        }\n        return sessionSpaceId.equals(currentSpaceId);\n    }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentdebug/impl/AgentDebugServiceImpl.java#L137-L173","documentation":"INSUFFICIENT_PERMISSIONS thrown by AgentDebugService.checkBotPermission when chatBotBaseMapper.checkBotPermission(botId, uid, spaceId) returns <= 0, meaning the user has no access to that bot in the given space.","triggerScenarios":"Creating/clearing a debug session or accessing messages for a bot the user cannot see in the current space (wrong spaceId, non-member, or bot belongs to another space).","commonSituations":"User switched spaces but client kept old spaceId; sharing/ACL not granted; debug URL copied from another user's session; bot deleted from the space.","solutions":["Verify the user is a member of the space owning the bot","Confirm spaceId in the request matches the space containing the bot","Request bot access/permissions from the space admin","Check checkBotPermission SQL/logic for the expected ACL rows"],"exampleFix":"// before\ndebugApi.create({ botId: 42, spaceId: 1 }); // user not in space 1\n// after\nconst spaceId = getCurrentUserSpace();\ndebugApi.create({ botId: 42, spaceId });","handlingStrategy":"validation","validationCode":"const canAccess = await checkBotAccess(botId, uid, spaceId); if (!canAccess) hideDebugPanel();","typeGuard":null,"tryCatchPattern":"try { await debugApi.create({botId, spaceId}); } catch (e) { if (e.code === 'INSUFFICIENT_PERMISSIONS') showNoAccessMessage(); }","preventionTips":["Send the spaceId the user is currently in","Gate debug UI by permission flags from the backend","Refresh ACLs after membership changes"],"tags":["permissions","space","bot-access"],"backgroundTag":"insufficient-permissions","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"}