alibaba/spring-ai-alibaba · error · org.springframework.ai.mybatisplus.exception.SerializationException
failed to dump data${data}
Error message
failed to dump data${data} What it means
Thrown by JsonSerializer.dump when Jackson's objectMapper.writeValueAsString throws JsonProcessingException while serializing the DSL data map to a JSON string. The original data is appended to the message (and the JsonProcessingException kept as cause) to aid diagnosis. In practice this occurs when the map contains non-serializable values such as cyclic references, Java objects without Jackson-compatible accessors, or invalid types inserted programmatically.
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/dsl/serialize/JsonSerializer.java:57
@Override
public Map<String, Object> load(String s) {
try {
Map<?, ?> value = objectMapper.readValue(s, Map.class);
return MapReadUtil.safeCastToMapWithStringKey(value);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String dump(Map<String, Object> data) {
String result;
try {
result = objectMapper.writeValueAsString(data);
}
catch (JsonProcessingException e) {
throw new SerializationException("failed to dump data" + data, e);
}
return result;
}
}
View on GitHub (pinned to f82da0b50f)
Solutions
- Inspect the cause (JsonProcessingException) to identify the unserializable value and replace it with a JSON-compatible type (Map/List/String/Number)
- Ensure any custom objects stored in the DSL map are Jackson-serializable (public getters or @JsonSerialize) or pre-converted via OBJECT_MAPPER.convertValue
- Break cyclic references in the data structure before dumping
- Configure the shared ObjectMapper (e.g. disable FAIL_ON_EMPTY_BEANS, register JavaTimeModule) if special types are expected
Example fix
// before
data.put("node", new MyNodeObject()); // not Jackson-serializable
// after
data.put("node", objectMapper.convertValue(new MyNodeObject(), Map.class)); Defensive patterns
Strategy: try-catch
Validate before calling
try {
OBJECT_MAPPER.writeValueAsString(data);
} catch (JsonProcessingException e) {
throw new IllegalStateException("DSL data is not JSON-serializable: " + e.getMessage());
} Try / catch
try { String json = jsonSerializer.dump(data); } catch (SerializationException e) { log.error("Serialization failed for data; cause: {}, offending data: {}", e.getCause(), e.getMessage(), e); throw e; } Prevention
- Store only JSON-compatible values (Map/List/String/Number/Boolean) in DSL maps
- Convert custom objects with ObjectMapper.convertValue before inserting them
- Avoid cyclic references in node data
- Configure the shared ObjectMapper for special types (dates, optionals, empty beans)
- Check the wrapped JsonProcessingException cause first when debugging
When it happens
Trigger: dump() called on a data map containing objects Jackson cannot serialize (no getters, cycles, ObjectMapper-visible failures); JsonNode mixed with unserializable custom objects; data mutated after parse to include non-JSON types like Date without a configured serializer; infinite recursion via self-referencing structures.
Common situations: Saving an app after a converter inserted a live Java object instead of a JSON-compatible value; plugin/converter bugs leaking typed objects into the DSL map; ObjectMapper misconfiguration (e.g. failing on empty beans); large cyclic graphs of node data.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- Failed to parse 'advanced_settings.groups' JSON
- 序列化 defaultParameters 失败
- 序列化 supportedParameters 失败
- Failed to build JSON-RPC payload
- Failed to build JSON-RPC streaming payload
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/3981175390f45b1a.
Report an issue: GitHub.