iflytek/astron-agent · error · BusinessException
convertTextErrorCodeToResponseEnum(listener.getErrorCode())
Error message
convertTextErrorCodeToResponseEnum(listener.getErrorCode())
What it means
After the WebSocket exchange finishes, generateText inspects listener.getErrorCode(); if the Spark AI service reported an error frame, the raw numeric code is converted via convertTextErrorCodeToResponseEnum into a specific ResponseEnum and thrown as a BusinessException. The message shown is the converter call site — the actual thrown enum depends on the mapped Spark error code (401, 10000-11203 etc.), or SYSTEM_ERROR for unmapped codes.
Solutions
- Read the logged 'AI service error: ...' message to get the numeric Spark code and map it to its documented cause
- For 401/11200/11203-style codes: fix the platform API key/secret/appId configuration in the platform account settings
- For 11201/11202/11203/10006: apply for higher quota or add rate limiting/backoff on the caller side
- For 10005/10163: verify the 'domain' argument matches the TEXT_HOST_URL API version (v4.0)
Example fix
// before
ResponseEnum responseEnum = convertTextErrorCodeToResponseEnum(listener.getErrorCode());
throw new BusinessException(responseEnum);
// after
ResponseEnum responseEnum = convertTextErrorCodeToResponseEnum(listener.getErrorCode());
log.error("Spark text API error code {} mapped to {}", listener.getErrorCode(), responseEnum);
throw new BusinessException(responseEnum); Defensive patterns
Strategy: try-catch
Validate before calling
// validate config before call
if (StrUtil.isBlank(config.getPlatformApiKey()) || StrUtil.isBlank(config.getPlatformApiSecret()) || StrUtil.isBlank(domain)) { throw new BusinessException(ResponseEnum.CONFIG_ERROR); } Try / catch
try { return client.generateText(q, domain, 60); } catch (BusinessException e) { switch (e.getCode()) { case RATE_LIMIT_CODES: sleepAndRetry(); break; case AUTH_CODES: alertConfigIssue(); break; default: throw e; } } Prevention
- Map the numeric Spark code from logs to its documented cause
- Keep API keys/quotas monitored (401, 11200-11203)
- Apply client-side rate limiting to avoid QPS/concurrency codes
- Verify domain matches the endpoint API version
When it happens
Trigger: The Spark chat API sends a WebSocket message with header.code != 0 (e.g. 401 auth failure captured in onFailure, 10005 param error, 11202 QPS limit, 10013/10014 content audit failures) before the exchange completes.
Common situations: Wrong/expired API key or secret (401/11200), exhausted free tier or daily quota (11201), exceeding QPS/concurrency limits (11202/11203/10006), invalid 'domain' value for the API version (10005/10163), or content-policy rejections (10013/10014/10019/10021).
Related errors
- Invalid host URL or authentication parameters
- User UID cannot be null
- Timed out acquiring distributed lock, please try again later
- Current user does not exist
- Distributed lock acquisition timeout, please try again later
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/b8202d0cf1c7716c.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java:219
listener = new TextGenerationWebSocketListener(
config.getPlatformAppId(), question, domain, latch, totalAnswer);
httpClient.newWebSocket(request, listener);
if (!latch.await(seconds, TimeUnit.SECONDS)) {
log.error("AI text generation request timeout, timeout: {} seconds", seconds);
throw new BusinessException(ResponseEnum.SYSTEM_ERROR);
}
// Check if AI service returned an error
if (listener.getErrorCode() != null) {
String errorMsg = listener.getErrorMessage() != null
? listener.getErrorMessage()
: "AI service error, code: " + listener.getErrorCode();
log.error("AI service error: {}", errorMsg);
// Convert error code to corresponding ResponseEnum and throw
ResponseEnum responseEnum = convertTextErrorCodeToResponseEnum(listener.getErrorCode());
throw new BusinessException(responseEnum);
}
String result = totalAnswer.toString().trim();
if (result.isEmpty()) {
throw new BusinessException(ResponseEnum.SYSTEM_ERROR);
}
return result;
} catch (Exception e) {
log.error("AI text generation service call exception", e);
if (e instanceof BusinessException) {
throw e;
}
throw new BusinessException(ResponseEnum.SYSTEM_ERROR);
}
}
/**View on GitHub (pinned to 5e758547a8)