Skip to content

build_communities crashes on nested attribute values with Neo4j (TypeError: Property values can only be of primitive types) #1399

@Ataxia123

Description

@Ataxia123

Summary

When the LLM extraction path produces entities or edges with nested Map/List attributes (e.g. a dict of lists, or a list of dicts), writing them to Neo4j via the bulk path raises:

Neo.ClientError.Statement.TypeError
Property values can only be of primitive types or arrays thereof.
Encountered: Map{...}

and the whole build_communities / bulk-add call fails. The Kuzu backend already handles this case by serializing attributes — Neo4j needs the same treatment.

Reproduction

Any extraction that yields a nested attribute. Minimal example: an entity whose extracted attributes look like {"metadata": {"tags": ["x", "y"]}} or {"history": [{"year": 2020, "event": "..."}]}.

Expected

Nested attributes round-trip through Neo4j without crashing the write, matching the Kuzu backend's behavior.

Actual

Neo4j rejects the write because attributes are currently spread as individual node properties instead of serialized.

Proposed fix

I've opened #1109 with a fix that serializes attributes to JSON for the Neo4j write path (mirroring what bulk_utils.py already does for Kuzu) and updates the read path to transparently handle both JSON strings and the legacy dict format, so existing data keeps working. The PR has been waiting for review since December — happy to rebase or adjust the approach if there's a different direction you'd prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions