alibaba/spring-ai-alibaba · error · IllegalStateException
Result is null, cannot extract response text
Error message
Result is null, cannot extract response text
What it means
extractResponseText pulls human-readable text out of the result map produced by A2A response parsing; it throws this IllegalStateException immediately when the result map itself is null, since there is nothing to extract text from.
Source
Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java:546
}
}
catch (Exception e) {
continue;
}
}
}
if (lastResult == null) {
throw new IllegalStateException("Failed to parse any valid result from streaming response");
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("result", lastResult);
return resultMap;
}
private String extractResponseText(Map<String, Object> result) {
if (result == null) {
throw new IllegalStateException("Result is null, cannot extract response text");
}
if ("status-update".equals(result.get("kind"))) {
Map<String, Object> status = (Map<String, Object>) result.get("status");
if (status != null) {
String state = (String) status.get("state");
if ("completed".equals(state)) {
return "";
}
else if ("processing".equals(state)) {
return "";
}
else if ("failed".equals(state)) {
return "";
}
else if ("working".equals(state)) {
Map<String, Object> message = (Map<String, Object>) status.get("message");
if (message != null && message.containsKey("parts")) {View on GitHub (pinned to f82da0b50f)
Solutions
- Guard against null before calling the text extraction helpers, e.g. result != null ? action.responseText(result) : ""
- Fix the upstream step so it always returns a non-null result map (even an empty one with kind/status keys)
- Catch IllegalStateException around the helper and supply a default message
Example fix
// before String text = action.responseText(result); // result may be null // after String text = (result != null) ? action.responseText(result) : "";
Defensive patterns
Strategy: type-guard
Validate before calling
if (result == null) { /* skip or default */ } Type guard
boolean hasResult(Map<String,Object> r) { return r != null && r.get("kind") != null; } Try / catch
try {
String text = action.responseText(result);
} catch (IllegalStateException e) {
String text = ""; // default when result map is absent
} Prevention
- Never pass through possibly-null parse results; normalize to empty maps
- Check state keys exist before reading them for downstream helpers
- Add assertions/tests that upstream nodes always produce the result key
When it happens
Trigger: Calling responseText(), text(), or responseText2() with a null result map — typically when an upstream parse step returned null and the null was propagated instead of being handled.
Common situations: Chaining A2aNodeActionWithConfig response helpers on the output of a failed/absent parse; passing a variable from an earlier node that never populated the state key; tests calling the helper directly with null.
Related errors
- No valid text content found in result:
- ${type} requires valid configuration
- Version ID cannot be null
- Failed to parse any valid result from streaming response
- Failed to build JSON-RPC payload
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/8de2da5534f1715a.
Report an issue: GitHub.