{"record":{"id":"bf0e61b05d2f6148","repo":"alibaba/spring-ai-alibaba","slug":"serialization-http-body-map-failed","errorCode":null,"errorMessage":"serialization Http body map failed","messagePattern":"serialization Http body map failed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/workflow/sections/HttpNodeSection.java","lineNumber":74,"sourceCode":"\t\t\tsb.append(String.format(\".url(\\\"%s\\\")%n\", escape(d.getUrl())));\n\t\t}\n\n\t\tfor (Map.Entry<String, String> entry : d.getHeaders().entrySet()) {\n\t\t\tsb.append(String.format(\".header(\\\"%s\\\", \\\"%s\\\")%n\", escape(entry.getKey()), escape(entry.getValue())));\n\t\t}\n\n\t\tfor (Map.Entry<String, String> entry : d.getQueryParams().entrySet()) {\n\t\t\tsb.append(String.format(\".queryParam(\\\"%s\\\", \\\"%s\\\")%n\", escape(entry.getKey()), escape(entry.getValue())));\n\t\t}\n\n\t\tif (d.getRawBodyMap() != null && !d.getRawBodyMap().isEmpty()\n\t\t\t\t&& !\"none\".equals(d.getRawBodyMap().get(\"type\"))) {\n\t\t\tString rawJson;\n\t\t\ttry {\n\t\t\t\trawJson = new ObjectMapper().writeValueAsString(d.getRawBodyMap());\n\t\t\t}\n\t\t\tcatch (JsonProcessingException e) {\n\t\t\t\tthrow new RuntimeException(\"serialization Http body map failed\", e);\n\t\t\t}\n\t\t\tsb.append(String.format(\".body(HttpNode.HttpRequestNodeBody.fromJson(\\\"%s\\\"))%n\", escape(rawJson)));\n\t\t}\n\n\t\tHttpNode.AuthConfig ac = d.getAuthConfig();\n\t\tif (ac != null) {\n\t\t\tif (ac.isBasic()) {\n\t\t\t\tsb.append(String.format(\".auth(HttpNode.AuthConfig.basic(\\\"%s\\\", \\\"%s\\\"))%n\", escape(ac.getUsername()),\n\t\t\t\t\t\tescape(ac.getPassword())));\n\t\t\t}\n\t\t\telse if (ac.isBearer()) {\n\t\t\t\tsb.append(String.format(\".auth(HttpNode.AuthConfig.bearer(\\\"%s\\\"))%n\", escape(ac.getToken())));\n\t\t\t}\n\t\t}\n\n\t\tHttpNode.RetryConfig rc = d.getRetryConfig();\n\t\tif (rc != null) {\n\t\t\tsb.append(String.format(\".retryConfig(new HttpNode.RetryConfig(%d, %d, %b))%n\", rc.getMaxRetries(),","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/workflow/sections/HttpNodeSection.java#L56-L92","documentation":"HttpNodeSection.render serializes the node's rawBodyMap to JSON with a fresh ObjectMapper to embed it in generated code as HttpRequestNodeBody.fromJson(...). A JsonProcessingException is wrapped in this RuntimeException. This is essentially an internal invariant: a Map serialization should rarely fail unless a value type is unserializable (e.g. an object with no properties or an invalid nested type).","triggerScenarios":"render(node, varName) on an HTTP node whose rawBodyMap has a non-'none' type and contains a value Jackson cannot serialize (self-referencing map, non-serializable object placed in the body map).","commonSituations":"Imported workflow JSON carried an exotic body value type; a custom deserializer produced a Map containing a Java object rather than JSON primitives.","solutions":["Inspect the HTTP node's rawBodyMap in the workflow definition and replace non-JSON values with plain strings/numbers/maps.","Re-export or fix the source workflow JSON so the body contains only JSON-compatible values.","If it persists, report it as a generator bug — Map serialization with ObjectMapper should not throw for valid definitions."],"exampleFix":"// before (node data)\nrawBodyMap: {\"type\":\"json\",\"value\": SomeJavaObject}\n// after\nrawBodyMap: {\"type\":\"json\",\"value\": \"{\\\"k\\\":1}\"} // JSON-compatible values only","handlingStrategy":"try-catch","validationCode":"boolean jsonSafe(Object v) {\n  if (v instanceof Map<?,?> m) return m.values().stream().allMatch(This::jsonSafe);\n  return v == null || v instanceof String || v instanceof Number || v instanceof Boolean || v instanceof java.util.List;\n}","typeGuard":"if (!(d.getRawBodyMap().values().stream().allMatch(Validator::jsonSafe))) throw new IllegalArgumentException(\"rawBodyMap contains non-JSON values\");","tryCatchPattern":"try { section.render(node, varName); } catch (RuntimeException e) { if (e.getMessage().contains(\"serialization Http body map failed\")) { /* sanitize node body values */ } throw e; }","preventionTips":["Keep HTTP node body maps limited to JSON-compatible values","Sanitize imported workflow definitions before generation","Report occurrences as generator bugs — plain Maps should always serialize"],"tags":["jackson","serialization","http-node"],"backgroundTag":"json-serialization-failed","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"}