iflytek/astron-agent · error · BusinessException
INSUFFICIENT_PERMISSIONS
INSUFFICIENT_PERMISSIONS
Error message
INSUFFICIENT_PERMISSIONS
What it means
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.
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
Example fix
// before
debugApi.create({ botId: 42, spaceId: 1 }); // user not in space 1
// after
const spaceId = getCurrentUserSpace();
debugApi.create({ botId: 42, spaceId }); Defensive patterns
Strategy: validation
Validate before calling
const canAccess = await checkBotAccess(botId, uid, spaceId); if (!canAccess) hideDebugPanel();
Try / catch
try { await debugApi.create({botId, spaceId}); } catch (e) { if (e.code === 'INSUFFICIENT_PERMISSIONS') showNoAccessMessage(); } Prevention
- Send the spaceId the user is currently in
- Gate debug UI by permission flags from the backend
- Refresh ACLs after membership changes
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.
Related errors
- INSUFFICIENT_PERMISSIONS
- msg (dynamic; logged as '无法录音:'+msg and shown via…
- msg (dynamic; logged as '无法录音:'+msg and shown via…
- errMsg (dynamic; logged as…
- code (dynamic; from e.name||e.message, logged as '请求录音权限错误')
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/4e7169dcaef22022.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentdebug/impl/AgentDebugServiceImpl.java:155
update.setIsDelete(1);
update.setUpdateTime(LocalDateTime.now());
LambdaUpdateWrapper<AgentDebugSession> updateWrapper = Wrappers.lambdaUpdate(AgentDebugSession.class)
.eq(AgentDebugSession::getBotId, botId)
.eq(AgentDebugSession::getUid, uid)
.eq(AgentDebugSession::getIsDelete, 0);
addSpaceCondition(updateWrapper, spaceId);
sessionMapper.update(update, updateWrapper);
}
private void validateUser(String uid) {
if (StringUtils.isBlank(uid)) {
throw new BusinessException(ResponseEnum.UNAUTHORIZED);
}
}
private void checkBotPermission(String uid, Long spaceId, Integer botId) {
if (botId == null || chatBotBaseMapper.checkBotPermission(botId, uid, spaceId) <= 0) {
throw new BusinessException(ResponseEnum.INSUFFICIENT_PERMISSIONS);
}
}
private AgentDebugSession findAccessibleSession(String uid, Long spaceId, String sessionId) {
AgentDebugSession session = findSession(uid, sessionId);
if (!isSameSpace(session.getSpaceId(), spaceId)) {
throw new BusinessException(ResponseEnum.DATA_NOT_FOUND);
}
checkBotPermission(uid, spaceId, session.getBotId());
return session;
}
private boolean isSameSpace(Long sessionSpaceId, Long currentSpaceId) {
if (sessionSpaceId == null || currentSpaceId == null) {
return sessionSpaceId == null && currentSpaceId == null;
}
return sessionSpaceId.equals(currentSpaceId);
}View on GitHub (pinned to 5e758547a8)