iflytek/astron-agent · error · BusinessException
RESPONSE_FAILED
RESPONSE_FAILED
Error message
code
What it means
CommonTool.checkSystemCallResponse(String resp) parses a downstream system-call response as a fastjson2 JSONObject and enforces the platform convention code==0 for success. When the 'code' field is any non-zero value, it throws BusinessException(RESPONSE_FAILED) carrying the numeric code as the error message and the remote 'message' field as a template argument. The resulting exception's getMessage() is literally the remote code string (e.g. '500'), which is why this error shows up with the generic message 'code'.
Solutions
- Look at the second template argument of the BusinessException (the remote 'message' field) or catch the exception and inspect its args to learn the real reason returned by the downstream system.
- Call the downstream API directly (curl/Postman with the same payload) to reproduce the non-zero code and consult that system's error-code table.
- Fix the request: renew credentials, correct parameters, or retry after the remote service recovers, then confirm code==0.
- Improve the call site: wrap checkSystemCallResponse and log the full raw response so future failures are diagnosable.
Example fix
// before
Object data = CommonTool.checkSystemCallResponse(resp);
// after
try {
Object data = CommonTool.checkSystemCallResponse(resp);
} catch (BusinessException e) {
log.error("system call failed, raw resp={}", resp, e);
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
JSONObject precheck = JSON.parseObject(resp);
if (precheck.getInteger("code") == null || precheck.getInteger("code") != 0) {
log.error("downstream call will fail checkSystemCallResponse: code={}, message={}",
precheck.getInteger("code"), precheck.getString("message"));
} Try / catch
try {
Object data = CommonTool.checkSystemCallResponse(resp);
} catch (BusinessException e) {
String remoteCode = e.getMessage(); // numeric remote code
log.error("system call rejected: remoteCode={}, raw={}", remoteCode, resp, e);
throw new BusinessException(ResponseEnum.RESPONSE_FAILED, "downstream system call failed: " + remoteCode);
} Prevention
- Always log the raw response string at the call site — the exception alone only carries the numeric code.
- Pre-check resp for null/blank/invalid JSON before calling checkSystemCallResponse to avoid masking JSON errors as code!=0 flows.
- Maintain a mapping of downstream error codes to actionable messages for the systems you call.
- Add contract tests asserting code==0 envelopes from each integrated downstream service.
When it happens
Trigger: Any HTTP call whose response is fed into checkSystemCallResponse and whose JSON body has code != 0 — e.g. the target system returns {"code":500,...}, {"code":401,...} for auth failure, or a business-error code from a model/agent/tool backend.
Common situations: Downstream service outages or 5xx mapped into a JSON envelope; invalid or expired credentials/tokens for the target system; request parameters the remote API rejects; version drift where the remote service changed its error codes; and integration debugging where the dev only sees 'code' without knowing the wrapped remote message.
Related errors
- 上传失败
- jsonData.message
- response.data.message
- errorMessage (dynamic; error.message or fallback 'Failed to…
- PERSONALITY_AI_GENERATE_PARAM_EMPTY
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a0673289a21f4e04.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/tool/CommonTool.java:86
if (jsonObject.getInteger("code") != 0) {
log.error("resp code not 0, resp = {}", resp);
}
} catch (JSONException je) {
log.error("resp parse to json err, resp = {}", resp);
}
}
/**
* Check system call response and throw exception if failed
*
* @param resp The response string to validate
* @return The data object from response if successful
* @throws BusinessException if response code is not 0
*/
public static Object checkSystemCallResponse(String resp) {
JSONObject jsonObject = JSON.parseObject(resp);
if (jsonObject.getInteger("code") != 0) {
throw new BusinessException(ResponseEnum.RESPONSE_FAILED, String.valueOf(jsonObject.getInteger("code")), jsonObject.getString("message"));
}
return jsonObject.get("data");
}
public static ModelConfigProtocolDto getModelConfig(String s) {
return JSON.parseObject(s).getObject("modelConfig", ModelConfigProtocolDto.class);
}
public static ModelConfigProtocolDto getModelConfig(JSONObject jsonObject) {
return jsonObject.getObject("modelConfig", ModelConfigProtocolDto.class);
}
public static List<String> getToolIds(List<Tool> tools) {
if (tools.isEmpty()) {
return new ArrayList<>();
}
return tools.stream().map(Tool::getToolId).collect(Collectors.toList());
}View on GitHub (pinned to 5e758547a8)