iflytek/astron-agent · error · BusinessException

UNAUTHORIZED

UNAUTHORIZED

Error message

ResponseEnum.UNAUTHORIZED

What it means

AgentMemoryServiceImpl.validateUser throws UNAUTHORIZED when the uid argument is blank. Every public entry point (getConfig, saveConfig, listMemories, deleteMemory, clearMemories) funnels through it, so this means the request reached the service without an authenticated user id.

Solutions

  1. Ensure the request carries a valid authentication token/session so the framework resolves the uid.
  2. Re-authenticate if the token expired, then retry.
  3. Check that the auth interceptor/filter correctly extracts and forwards uid to the service layer.

Example fix

// before
httpClient.get("/agent-memory/config?botId=1"); // no auth header
// after
httpClient.get("/agent-memory/config?botId=1",
    { headers: { Authorization: `Bearer ${token}` } });
Defensive patterns

Strategy: try-catch

Validate before calling

if (!authToken || isExpired(authToken)) { await reauthenticate(); }

Try / catch

try { await memApi.getConfig(botId); } catch (e) { if (e.status === 401 || e.code === 'UNAUTHORIZED') { redirectToLogin(); } }

Prevention

When it happens

Trigger: Any agent-memory endpoint invoked with a null/empty uid — typically a missing, expired, or malformed auth token so the interceptor did not populate the uid context.

Common situations: Calling the API without a login session; token expired so user context resolution failed; internal calls that bypass the auth filter and pass uid=null.

Understand the failure class

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/c0503e1c5f6b2e3a. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentmemory/impl/AgentMemoryServiceImpl.java:223

                item.createdAt(),
                item.updatedAt());
    }

    private AgentMemoryConfigDto defaultDto(Integer botId) {
        AgentMemoryConfigDto dto = new AgentMemoryConfigDto();
        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;
    }

View on GitHub (pinned to 5e758547a8)