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

  1. Re-authenticate and retry with a valid session/token
  2. Ensure the auth filter populates uid for this route
  3. Check gateway/proxy forwards the Authorization header
  4. 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

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

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)