{"record":{"id":"48b59c3230c32e67","repo":"alibaba/spring-ai-alibaba","slug":"unsupported-body-type-raw-getclass","errorCode":null,"errorMessage":"Unsupported body type: {raw.getClass()}","messagePattern":"Unsupported body type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/HttpNode.java","lineNumber":704,"sourceCode":"\t\t\t\t\t\t\t\tObject fn = item.get(\"filename\");\n\t\t\t\t\t\t\t\tif (fn instanceof String) {\n\t\t\t\t\t\t\t\t\tbd5.setFilename((String) fn);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tObject mt = item.get(\"mimeType\");\n\t\t\t\t\t\t\t\tif (mt instanceof String) {\n\t\t\t\t\t\t\t\t\tbd5.setMimeType((String) mt);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlist3.add(bd5);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn new HttpRequestNodeBody(BodyType.BINARY, list3);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn new HttpRequestNodeBody(BodyType.NONE, null);\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn new HttpRequestNodeBody(BodyType.NONE, null);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new IllegalArgumentException(\"Unsupported body type: \" + raw.getClass());\n\t\t}\n\n\t\tpublic BodyType getType() {\n\t\t\treturn type;\n\t\t}\n\n\t\tpublic void setType(BodyType type) {\n\t\t\tthis.type = type;\n\t\t}\n\n\t\tpublic List<BodyData> getData() {\n\t\t\treturn data;\n\t\t}\n\n\t\tpublic void setData(List<BodyData> data) {\n\t\t\tthis.data = data;\n\t\t}\n","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/HttpNode.java#L686-L722","documentation":"HttpNode's HttpRequestNodeBody.of(...) converts a raw request-body value into a typed HttpRequestNodeBody based on its runtime class. When the raw value is not one of the handled types (String, JSON structures, etc.) the switch falls through and an IllegalArgumentException naming the offending class is thrown. It is a static type-dispatch guard: the body type configured for the HTTP request node is not supported.","triggerScenarios":"Configuring an HttpExecuter/HttpRequestNodeBody with a raw body object whose class is not handled by the switch — e.g. passing a POJO, byte[], Map of unexpected shape, or null-typed object where only String/structured types are supported.","commonSituations":"Users set the HTTP node request body to a serialized Java object instead of a JSON string; workflow DSL yields a typed value the body factory doesn't recognize; refactors change bodyType/raw value pairing inconsistently.","solutions":["Convert the body to a supported representation (e.g. JSON String) before passing it to of(...).","Check the default branch of the switch to see exactly which classes are supported and which class is being passed.","If a new type is genuinely needed, add a case for it in the switch mapping to the correct BodyType.","Validate bodyType vs raw payload at node-build time to fail early with a clearer message."],"exampleFix":"// before\nHttpRequestNodeBody body = HttpRequestNodeBody.of(myPojo);\n// after\nHttpRequestNodeBody body = HttpRequestNodeBody.of(objectMapper.writeValueAsString(myPojo));","handlingStrategy":"type-guard","validationCode":"if (!(raw instanceof String) && !(raw instanceof Map) && !(raw instanceof List)) {\n    throw new IllegalArgumentException(\"HTTP body must be String/Map/List, got \" + raw.getClass());\n}","typeGuard":"boolean isSupportedBodyType(Object raw) {\n    return raw instanceof String || raw instanceof Map<?,?> || raw instanceof List<?>;\n}","tryCatchPattern":"try {\n    HttpRequestNodeBody body = HttpRequestNodeBody.of(raw);\n} catch (IllegalArgumentException e) {\n    raw = objectMapper.writeValueAsString(raw); // fallback to JSON string\n    HttpRequestNodeBody body = HttpRequestNodeBody.of(raw);\n}","preventionTips":["Pass bodies as JSON strings unless the API documents structured types.","Don't pass POJOs/byte[] directly into body factories.","Validate bodyType/raw pairing at node construction.","Add a unit test for every BodyType you configure."],"tags":["http-request","type-dispatch","illegal-argument"],"backgroundTag":"unsupported-operation","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"}