alibaba/spring-ai-alibaba · error · RuntimeException
Failed to deserialize store item
Error message
Failed to deserialize store item
What it means
resultSetToStoreItem() deserializes the namespace and value JSON columns via Jackson and constructs a StoreItem; any exception (JsonProcessingException, null timestamp, malformed row) is wrapped in this RuntimeException. It means a row in the table could not be converted back into a StoreItem.
Source
Thrown at spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java:905
*/
@SuppressWarnings("unchecked")
private StoreItem resultSetToStoreItem(ResultSet rs) {
try {
String namespaceJson = rs.getString("namespace");
String key = rs.getString("key_name");
String valueJson = rs.getString("value_json");
Timestamp createdAt = rs.getTimestamp("created_at");
Timestamp updatedAt = rs.getTimestamp("updated_at");
objectMapper.findAndRegisterModules();
JavaType namespaceType = objectMapper.getTypeFactory().constructCollectionType(List.class, String.class);
JavaType valueType = objectMapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class);
List<String> namespace = objectMapper.readValue(namespaceJson, namespaceType);
Map<String, Object> value = objectMapper.readValue(valueJson, valueType);
return new StoreItem(namespace, key, value, createdAt.getTime(), updatedAt.getTime());
} catch (Exception e) {
throw new RuntimeException("Failed to deserialize store item", e);
}
}
}
View on GitHub (pinned to f82da0b50f)
Solutions
- Find the offending row(s) by checking id/key in the chained cause or querying rows with invalid JSON.
- Fix or delete the corrupt rows (they are otherwise skipped in bulk reads as 'invalid items').
- Ensure timestamps columns are NOT NULL and populated.
- Keep the table schema and StoreItem serialization version in sync across library upgrades; migrate old rows.
Example fix
// before
UPDATE store_table SET value_json = 'not json' WHERE id = 'x';
// after
UPDATE store_table SET value_json = '{"valid":"json"}' WHERE id = 'x'; Defensive patterns
Strategy: validation
Validate before calling
// scan for corrupt rows before listing // SELECT id FROM store_table WHERE NOT JSON_VALID(value_json); (MySQL)
Try / catch
try { StoreItem i = store.getItem(ns, key); } catch (RuntimeException e) { if (e.getMessage().contains("deserialize")) { log.error("corrupt row: {}", e.getCause()); } throw e; } Prevention
- Never hand-edit store table contents directly
- Add NOT NULL constraints on created_at/updated_at columns
- Migrate JSON data when upgrading library versions
- Use JSON_VALID checks in DB maintenance scripts
When it happens
Trigger: Reading a row whose value_json or namespace_json is corrupt, hand-edited, written by an incompatible schema version, or whose timestamp columns are NULL.
Common situations: Manual UPDATEs to the table; version upgrade changing StoreItem JSON shape; NULL created_at/updated_at inserted by external scripts; truncation of JSON by narrow columns.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
Related errors
- 序列化 defaultParameters 失败
- 序列化 supportedParameters 失败
- JSON processing failed:
- Status value cannot be null
- Unknown status: ${value}. Valid values are: pending, in_prog
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/a59897fabf9a89a0.
Report an issue: GitHub.