{"record":{"id":"8de2da5534f1715a","repo":"alibaba/spring-ai-alibaba","slug":"result-is-null-cannot-extract-response-text","errorCode":null,"errorMessage":"Result is null, cannot extract response text","messagePattern":"Result is null, cannot extract response text","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java","lineNumber":546,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (lastResult == null) {\n\t\t\tthrow new IllegalStateException(\"Failed to parse any valid result from streaming response\");\n\t\t}\n\t\tMap<String, Object> resultMap = new HashMap<>();\n\t\tresultMap.put(\"result\", lastResult);\n\t\treturn resultMap;\n\t}\n\n\tprivate String extractResponseText(Map<String, Object> result) {\n\t\tif (result == null) {\n\t\t\tthrow new IllegalStateException(\"Result is null, cannot extract response text\");\n\t\t}\n\n\t\tif (\"status-update\".equals(result.get(\"kind\"))) {\n\t\t\tMap<String, Object> status = (Map<String, Object>) result.get(\"status\");\n\t\t\tif (status != null) {\n\t\t\t\tString state = (String) status.get(\"state\");\n\t\t\t\tif (\"completed\".equals(state)) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\telse if (\"processing\".equals(state)) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\telse if (\"failed\".equals(state)) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\telse if (\"working\".equals(state)) {\n\t\t\t\t\tMap<String, Object> message = (Map<String, Object>) status.get(\"message\");\n\t\t\t\t\tif (message != null && message.containsKey(\"parts\")) {","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/a2a/A2aNodeActionWithConfig.java#L528-L564","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nString text = action.responseText(result); // result may be null\n// after\nString text = (result != null) ? action.responseText(result) : \"\";","handlingStrategy":"type-guard","validationCode":"if (result == null) { /* skip or default */ }","typeGuard":"boolean hasResult(Map<String,Object> r) { return r != null && r.get(\"kind\") != null; }","tryCatchPattern":"try {\n    String text = action.responseText(result);\n} catch (IllegalStateException e) {\n    String text = \"\"; // default when result map is absent\n}","preventionTips":["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"],"tags":["null-check","a2a","response-parsing"],"backgroundTag":"null-argument","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}