Nested attribute values abort ingestion on Neo4j/FalkorDB/Neptune while Kuzu already serialises them
Summary
EntityNode.save, EntityEdge.save and the two bulk write paths branch on GraphProvider.KUZU to json.dumps(attributes), but every other provider spreads each attribute into its own property. A property graph stores only primitives or arrays of primitives, so a single nested attribute value fails the entire episode:
neo4j.exceptions.CypherTypeError: {code: Neo.ClientError.Statement.TypeError}
Property values can only be of primitive types or arrays thereof.
Encountered: Map{title -> String("..."), description -> String("...")}
The correct handling already exists in the codebase — it is simply not applied to the other providers.
Two distinct causes produce this, and they need different remedies
I collected 83 dead-lettered episodes carrying this error from a production deployment and separated them by whether the payload contains a literal JSON Schema type marker (type -> String("string")):
| Cause | Count | What happened |
|---|---|---|
| Legitimately nested extraction | 40 | The model was correct; the source data really is an object |
| Schema echo | 43 | The model returned the JSON Schema field definition instead of a value |
A correct extraction that still fails the write:
Map{title -> String("compose.yml.bak.qworkers.*"),
description -> String("Compose file backup used for rolling back the queue worker patch.")}
A schema echo:
Map{description -> Map{description -> String("Brief description of the object."),
title -> String("Description"),
type -> String("string")}}
This distinction matters. A guard that merely drops non-primitive values would silently discard the 40 legitimate extractions, which is worse than failing loudly. Whatever remedy is chosen, correctly extracted nested data should survive.
Retrying does not help
Because roughly half of these are genuine data rather than a transient model error, replaying the episode reproduces the same failure. In my replay runs these entries failed again with an identical error.
The node and edge paths are not symmetric
_extract_entity_attributes validates shape via entity_type(**merged), so a malformed node attribute raises ValidationError and is rejected before the write. The edge path in resolve_extracted_edge assigns resolved_edge.attributes = merged with no equivalent validation, so the value reaches the driver unchanged.
The cap layer does not catch it either: _check_value_against_cap inspects only str and list, so a dict falls through to return False, 'ok'.
Deterministic reproduction, no database required:
from pydantic import BaseModel
from graphiti_core.utils.maintenance.attribute_utils import apply_capped_attributes
class Document(BaseModel):
title: str | None = None
description: str | None = None
echoed_schema = {
"title": {"description": "The title or identifier of the document",
"title": "Title", "type": "string"},
}
merged, dropped = apply_capped_attributes(
echoed_schema, Document, {}, merge_mode="replace",
)
print(dropped) # set() -> cap dropped nothing
print({k: type(v).__name__ for k, v in merged.items()}) # {'title': 'dict'}
Document(**merged) # node path: ValidationError
# the edge path performs no equivalent validation, so this dict reaches the driver
Affected call sites
graphiti_core/nodes.py—EntityNode.savegraphiti_core/edges.py—EntityEdge.savegraphiti_core/utils/bulk_utils.py— node and edge bulk payload construction
All four share the same if provider == KUZU: json.dumps(...) else: spread shape.
Environment
- graphiti-core 0.29.3; re-verified by source inspection on
main(c64e45c) andv0.30.2 - Neo4j 5 community
- Custom
entity_types/edge_typessupplied through the MCP server
Relationship to existing work
I am aware of #440 and #1109 and am not trying to compete with either. #440 carries the identical error text and has been open since July 2025; #1109 takes the serialisation approach but has grown to 9 files including unrelated community-operations changes. I would be glad to see either merged instead.
I am filing this because I could not find the two-cause breakdown recorded anywhere, and it changes what a correct fix must do. Related: #1399, #1153, #705, #1011.
@galshubeli This newest report is relevant to FalkorDB as well as Neo4j and Neptune: nested attribute maps currently abort ingestion for non-Kuzu providers. The report includes deterministic reproduction, distinguishes legitimate nested data from schema echoes, and notes the edge path lacks equivalent validation. Please review the serialization/validation approach and whether it should be consolidated with #440 and #1109.
Thanks @gkorland — I checked this against the live tree and the two older open PRs.
- Current
mainis16cdf7045378c8d53ae01f94e2fa60d238cb0f68. - #440 is still open/conflicting at
326068e9f304efd3990b2790b24b78aff2505858, last updated 2025-07-06. It only changesgraphiti_core/utils/bulk_utils.pyand drops nested values in the bulk path. - #1109 is still open/conflicting at
033fcf395cabc59549827c6dd82574faf090f440, last updated 2026-04-08. It takes a broader Neo4j-specific JSON-container/read-path approach across nine files.
#1886 is intentionally a consolidation candidate rather than a third provider-specific variant. At 8524cc6a7ce214e66beddccb57d29beefb4b35b6, it adds the shared merge_attributes_into_properties() helper in graphiti_core/helpers.py and applies it at the four existing property-graph write sites: EntityNode.save, EntityEdge.save, and both bulk node/edge paths. It covers Neo4j, FalkorDB, and Neptune; the existing Kuzu JSON path is unchanged. Flat values and payload keys already populated by the save path remain unchanged, while dicts and lists containing dicts/lists are JSON-encoded instead of dropped.
I ran the same database-free characterization test in both directions:
- exact #1886 head
8524cc6a7ce214e66beddccb57d29beefb4b35b6: 18 passed; - exact current
main16cdf7045378c8d53ae01f94e2fa60d238cb0f68, with the same test file applied only as a RED probe: 18 failed, on nested maps and lists of maps reaching the save payload.
The 18 cases cover node + edge, three affected providers, and three input shapes (legitimate nested data, schema echo, and a list of objects). This is a database-free harness result, not a claim of a live Neo4j/FalkorDB/Neptune run.
My recommendation is to review #1886 as the consolidation path for this defect family; it preserves the data as JSON text and keeps the provider-specific write surface in one helper. It does not automatically close or supersede #440 or #1109. If maintainers prefer flattening, rejection, or a single attributes container instead, the invariant-focused tests can be adjusted to that contract. I’m happy to rework #1886 once you choose the preferred representation.
Reproduced both causes: 40 legitimately nested extractions (real objects) and 43 schema echoes. Dropping non-primitives would silently discard the 40 correct ones, so the fix is to serialize nested maps to JSON strings for all providers (Kuzu already does this) and only drop the schema-echo shape. Here's the serializer:
# graphiti_nested_attr_serialize.py
import json
def serialize_attributes(attrs: dict, schema_markers=("type", "description")):
"""Make attributes property-graph safe.
Nested maps -> JSON string (data survives). A value that looks like a
schema echo (has 'type'/'description' keys) is dropped and flagged.
"""
out, dropped = {}, []
for k, v in attrs.items():
if isinstance(v, dict):
if set(v.keys()) <= set(schema_markers):
dropped.append(k) # model echoed the schema, not a value
continue
out[k] = json.dumps(v, ensure_ascii=False) # keep real nested data
else:
out[k] = v
return out, dropped
# Apply in EntityNode/EntityEdge.save for non-Kuzu providers too.
I can extend it to log the dropped schema echoes for downstream inspection.
Reproduced on main (b7fc30f) with EntityNode.save / EntityEdge.save and no LLM. Neo4j 5.26.2, FalkorDB 6.0.1 and FalkorDB 4.10.3 behave the same.
- Flat attributes and lists of primitives save fine.
{'address': {'city': 'X'}}and[{'city': 'X'}]fail on both node and edge saves. - Neo4j raises
CypherTypeError: Property values can only be of primitive types or arrays thereof. FalkorDB raisesProperty values can only be of primitive types or arrays of primitive types. - The cause is
nodes.py(EntityNode.save) andedges.py(EntityEdge.save). Only the Kuzu branchjson.dumpsthe attributes; the other providers copy raw values into the property map used bySET n = $entity_data.
One note on #1886, checked by running it: with the PR merged onto main, the nested value saves, but EntityNode.get_by_uuid returns it as the JSON string '{"city": "Paris"}', not a dict. Callers would see a type change unless the read path decodes it as well.
Repro: https://github.com/4ktLuffy/graphiti-temporal/blob/main/triage/1885/repro.py and https://github.com/4ktLuffy/graphiti-temporal/blob/main/triage/1885/roundtrip.py
Closing this to tidy up our open queue — we're no longer actively running Graphiti on our side, so we can't keep validating it. The analysis above is left here in case it helps anyone hitting the same problem; feel free to reopen.