alibaba/spring-ai-alibaba · error · RuntimeException
serialization Http body map failed
Error message
serialization Http body map failed
What it means
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).
Source
Thrown at 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:74
sb.append(String.format(".url(\"%s\")%n", escape(d.getUrl())));
}
for (Map.Entry<String, String> entry : d.getHeaders().entrySet()) {
sb.append(String.format(".header(\"%s\", \"%s\")%n", escape(entry.getKey()), escape(entry.getValue())));
}
for (Map.Entry<String, String> entry : d.getQueryParams().entrySet()) {
sb.append(String.format(".queryParam(\"%s\", \"%s\")%n", escape(entry.getKey()), escape(entry.getValue())));
}
if (d.getRawBodyMap() != null && !d.getRawBodyMap().isEmpty()
&& !"none".equals(d.getRawBodyMap().get("type"))) {
String rawJson;
try {
rawJson = new ObjectMapper().writeValueAsString(d.getRawBodyMap());
}
catch (JsonProcessingException e) {
throw new RuntimeException("serialization Http body map failed", e);
}
sb.append(String.format(".body(HttpNode.HttpRequestNodeBody.fromJson(\"%s\"))%n", escape(rawJson)));
}
HttpNode.AuthConfig ac = d.getAuthConfig();
if (ac != null) {
if (ac.isBasic()) {
sb.append(String.format(".auth(HttpNode.AuthConfig.basic(\"%s\", \"%s\"))%n", escape(ac.getUsername()),
escape(ac.getPassword())));
}
else if (ac.isBearer()) {
sb.append(String.format(".auth(HttpNode.AuthConfig.bearer(\"%s\"))%n", escape(ac.getToken())));
}
}
HttpNode.RetryConfig rc = d.getRetryConfig();
if (rc != null) {
sb.append(String.format(".retryConfig(new HttpNode.RetryConfig(%d, %d, %b))%n", rc.getMaxRetries(),View on GitHub (pinned to f82da0b50f)
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.
Example fix
// before (node data)
rawBodyMap: {"type":"json","value": SomeJavaObject}
// after
rawBodyMap: {"type":"json","value": "{\"k\":1}"} // JSON-compatible values only Defensive patterns
Strategy: try-catch
Validate before calling
boolean jsonSafe(Object v) {
if (v instanceof Map<?,?> m) return m.values().stream().allMatch(This::jsonSafe);
return v == null || v instanceof String || v instanceof Number || v instanceof Boolean || v instanceof java.util.List;
} Type guard
if (!(d.getRawBodyMap().values().stream().allMatch(Validator::jsonSafe))) throw new IllegalArgumentException("rawBodyMap contains non-JSON values"); Try / catch
try { section.render(node, varName); } catch (RuntimeException e) { if (e.getMessage().contains("serialization Http body map failed")) { /* sanitize node body values */ } throw e; } Prevention
- 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
When it happens
Trigger: 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).
Common situations: Imported workflow JSON carried an exotic body value type; a custom deserializer produced a Map containing a Java object rather than JSON primitives.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- 序列化 defaultParameters 失败
- 序列化 supportedParameters 失败
- Failed to serialize metadata record {}
- Failed to inspect metadata record {}
- Failed to apply serializer for metadata property {}
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/bf0e61b05d2f6148.
Report an issue: GitHub.