iflytek/astron-agent · error · BusinessException
SPARK_API_IMAGE_PARAM_ERROR
SPARK_API_IMAGE_PARAM_ERROR
Error message
SPARK_API_IMAGE_PARAM_ERROR
What it means
BotAIServiceClient.generateImage() throws SPARK_API_IMAGE_PARAM_ERROR when the iFlytek Spark image-generation HTTP endpoint returns status 401. Despite the 'param' name, this branch indicates authentication failure with the Spark open platform — the signed URL built from platformApiKey/platformApiSecret was rejected.
Solutions
- Verify the iFlytek open-platform API key and secret in the platform account configuration and re-issue if expired
- Confirm server clock is synchronized (NTP) since signed-URL auth is time-sensitive
- Compare the generated auth URL construction against current Spark API docs (host, headers, signature algorithm)
- Enable debug logging of the request (without leaking the key) and test the same credentials with a minimal Spark API call
Defensive patterns
Strategy: validation
Validate before calling
PlatformAccountConfigDto.IflytekOpenPlatformConfig cfg = platformAccountService.requireIflytekOpenPlatform();
if (cfg == null || StrUtil.isBlank(cfg.getPlatformApiKey()) || StrUtil.isBlank(cfg.getPlatformApiSecret())) {
throw new IllegalStateException("Spark open platform credentials missing or blank");
} Try / catch
try {
botAIServiceClient.generateImage(uid, prompt, size);
} catch (BusinessException e) {
if ("SPARK_API_IMAGE_PARAM_ERROR".equals(e.getCode())) {
// 401 from Spark: refresh/re-check platform API key & secret before retrying
} else throw e;
} Prevention
- Rotate and verify Spark API keys/secrets in platform account config regularly
- Keep server clocks NTP-synchronized for signed-URL auth
- Monitor 401 rates on the Spark image endpoint as an early credential-expiry signal
When it happens
Trigger: Calling generateImage(uid, prompt, size) when the configured platform API key/secret are invalid, expired, revoked, or the request signature (buildAuthenticatedUrl) is malformed/mis-timed, causing HTTP 401 from the image service.
Common situations: Wrong or rotated API credentials in the platform account config (platformAccountService.requireIflytekOpenPlatform); expired Spark open-platform keys; server clock skew breaking the HMAC auth signature; missing/incorrect host configuration.
Related errors
- convertImageErrorCodeToResponseEnum(responseCode)
- LOGIN_INFO_ERROR
- SYSTEM_ERROR
- convertTextErrorCodeToResponseEnum(listener.getErrorCode())
- Failed to build authentication URL
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a2629f33596033ba.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java:145
MediaType jsonMediaType = MediaType.get("application/json; charset=utf-8");
RequestBody requestBody = RequestBody.create(requestData.toString(), jsonMediaType);
Request request = new Request.Builder()
.url(requestUrl)
.post(requestBody)
.build();
try (Response response = httpClient.newCall(request).execute()) {
int code = response.code();
ResponseBody responseBody = response.body();
if (responseBody == null) {
throw new IllegalStateException("Image generation service response is empty");
}
if (code == 401) {
log.error("Image generation service authentication failed, user [{}]", uid);
throw new BusinessException(ResponseEnum.SPARK_API_IMAGE_PARAM_ERROR);
}
String responseBodyString = responseBody.string();
JSONObject result = JSONObject.parseObject(responseBodyString);
// Get error code from response
Integer responseCode = result.getJSONObject("header").getInteger("code");
if (responseCode == null) {
responseCode = result.getIntValue("header.code", -1);
}
log.info("Image generation request completed, user [{}], response code: {}", uid, responseCode);
// Check if there is an error
if (responseCode != 0) {
log.error("Image generation service returned error, user [{}], error code: {}", uid, responseCode);
// Convert error code to corresponding ResponseEnum and throwView on GitHub (pinned to 5e758547a8)