iflytek/astron-agent · error · BusinessException
INSUFFICIENT_PERMISSIONS
INSUFFICIENT_PERMISSIONS
Error message
ResponseEnum.INSUFFICIENT_PERMISSIONS
What it means
checkBotPermission throws INSUFFICIENT_PERMISSIONS when botId is null or the chatBotBaseMapper.checkBotPermission query returns <= 0, i.e. the user has no access to that bot within the given space. The bot exists elsewhere, belongs to another user, or is outside the space.
Solutions
- Verify the botId belongs to the requesting user in the given space (check chat_bot_base ownership/space columns).
- Grant the user access to the bot in that space if sharing is intended.
- Send the correct spaceId matching where the bot was created.
Example fix
// before memSvc.listMemories(uid, wrongSpaceId, botIdOfOtherSpace); // throws // after Long spaceId = botService.getSpaceIdOfBot(botId); // resolve correct space memSvc.listMemories(uid, spaceId, botId);
Defensive patterns
Strategy: validation
Validate before calling
const bot = await fetchBot(botId); if (!bot || bot.spaceId !== currentSpaceId) { throw new Error('no access to bot in this space'); } Type guard
boolean canUseBot(bot, uid, spaceId) { return bot != null && bot.uid === uid && bot.spaceId === spaceId; } Try / catch
try { await memApi.listMemories(botId, spaceId); } catch (e) { if (e.code === 'INSUFFICIENT_PERMISSIONS') { showNoAccessMessage(); } } Prevention
- Resolve botId and spaceId from the same source of truth (the bot detail API).
- Clear cached bot ids when switching accounts or workspaces.
- Grant collaborators access instead of sharing raw ids.
When it happens
Trigger: Calling getConfig/saveConfig/listMemories/deleteMemory/clearMemories with a botId the authenticated uid cannot access in the given spaceId, or with botId=null passing the earlier null-body check.
Common situations: Sharing a bot id between teammates without granting access; wrong spaceId (bot lives in another workspace); frontend cache holding a bot from a previous account.
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
- INSUFFICIENT_PERMISSIONS
- EXCEED_AUTHORITY
- Bot permission validation failed: botId=
- msg (dynamic; logged as '无法录音:'+msg and shown via…
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/4f07110bae72ef59.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentmemory/impl/AgentMemoryServiceImpl.java:229
dto.setBotId(botId);
dto.setProvider(Mem0MemoryProvider.PROVIDER);
dto.setEnabled(false);
dto.setHasApiKey(false);
dto.setAutoSearch(true);
dto.setSearchTopK(DEFAULT_TOP_K);
dto.setMinScore(DEFAULT_MIN_SCORE);
return dto;
}
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 void addSpaceCondition(LambdaQueryWrapper<AgentMemoryConfig> queryWrapper, Long spaceId) {
queryWrapper.eq(AgentMemoryConfig::getSpaceId, toStoredSpaceId(spaceId));
}
private String normalizeProvider(String provider) {
String normalized = StringUtils.upperCase(StringUtils.trimToEmpty(provider));
return StringUtils.isBlank(normalized) ? Mem0MemoryProvider.PROVIDER : normalized;
}
private int normalizeTopK(Integer topK) {
int value = topK == null ? DEFAULT_TOP_K : topK;
return Math.max(MIN_TOP_K, Math.min(MAX_TOP_K, value));
}
private double normalizeMinScore(Double minScore) {View on GitHub (pinned to 5e758547a8)