iflytek/astron-agent · error · BusinessException
UNAUTHORIZED
UNAUTHORIZED
Error message
UNAUTHORIZED
What it means
UNAUTHORIZED thrown by AgentDebugService.validateUser when the uid is blank. All agent-debug operations (list/create/get/save/delete/clear sessions) call it first; an empty user id means authentication context was missing.
Solutions
- Re-authenticate and retry with a valid session/token
- Ensure the auth filter populates uid for this route
- Check gateway/proxy forwards the Authorization header
- Verify the UID is resolved after the auth context is set
Defensive patterns
Strategy: try-catch
Validate before calling
if (!getUID()) redirectToLogin();
Try / catch
try { await debugApi.list(); } catch (e) { if (e.code === 'UNAUTHORIZED') redirectToLogin(); } Prevention
- Refresh tokens before expiry
- Forward auth headers through proxies/gateways
- Check auth context is set before service calls
When it happens
Trigger: Calling any agent-debug endpoint without a valid authenticated session, so the UID lookup yields null/blank.
Common situations: Expired or missing login token; auth header stripped by a proxy; calling the internal service directly bypassing the auth filter.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/b8438cd9659ee6d2.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentdebug/impl/AgentDebugServiceImpl.java:149
@Override
public void clearSessions(String uid, Long spaceId, Integer botId) {
validateUser(uid);
checkBotPermission(uid, spaceId, botId);
AgentDebugSession update = new AgentDebugSession();
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;
}
View on GitHub (pinned to 5e758547a8)