Skip to content

Conversation

@Ataxia123
Copy link

@Ataxia123 Ataxia123 commented Dec 17, 2025

Neo4j was crashing when entity/edge attributes contained nested structures (Maps of Lists, Lists of Maps) because attributes were being spread as individual properties instead of serialized to JSON strings.

Changes:

  • Serialize attributes to JSON for Neo4j (like Kuzu already does)
  • Update read path to handle both JSON strings and legacy dict format
  • Add integration tests for nested attribute structures
  • Maintain backward compatibility with existing code

Fixes issue where LLM extraction with complex structured attributes would cause: Neo.ClientError.Statement.TypeError - Property values can only be of primitive types or arrays thereof.

Modified Files:

  • graphiti_core/utils/bulk_utils.py: Serialize attributes for Neo4j
  • graphiti_core/nodes.py: Handle JSON string attributes in read path
  • graphiti_core/edges.py: Handle JSON string attributes in read path
  • graphiti_core/models/nodes/node_db_queries.py: Use n.attributes for Neo4j
  • graphiti_core/models/edges/edge_db_queries.py: Use e.attributes for Neo4j

New Files:

  • tests/test_neo4j_nested_attributes_int.py: Integration tests
  • docs/neo4j-attributes-fix.md: Comprehensive documentation

Summary

Brief description of the changes in this PR.

Type of Change

  • [x ] Bug fix
  • New feature
  • Performance improvement
  • Documentation/Tests

Objective

For new features and performance improvements: Clearly describe the objective and rationale for this change.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • All existing tests pass

Breaking Changes

  • This PR contains breaking changes

If this is a breaking change, describe:

  • What functionality is affected
  • Migration path for existing users

Checklist

  • Code follows project style guidelines (make lint passes)
  • Self-review completed
  • Documentation updated where necessary
  • No secrets or sensitive information committed

Related Issues

Closes #[issue number]

Neo4j was crashing when entity/edge attributes contained nested structures
(Maps of Lists, Lists of Maps) because attributes were being spread as
individual properties instead of serialized to JSON strings.

Changes:
- Serialize attributes to JSON for Neo4j (like Kuzu already does)
- Update read path to handle both JSON strings and legacy dict format
- Add integration tests for nested attribute structures
- Maintain backward compatibility with existing code

Fixes issue where LLM extraction with complex structured attributes
would cause: Neo.ClientError.Statement.TypeError - Property values
can only be of primitive types or arrays thereof.

Modified Files:
- graphiti_core/utils/bulk_utils.py: Serialize attributes for Neo4j
- graphiti_core/nodes.py: Handle JSON string attributes in read path
- graphiti_core/edges.py: Handle JSON string attributes in read path
- graphiti_core/models/nodes/node_db_queries.py: Use n.attributes for Neo4j
- graphiti_core/models/edges/edge_db_queries.py: Use e.attributes for Neo4j

New Files:
- tests/test_neo4j_nested_attributes_int.py: Integration tests
- docs/neo4j-attributes-fix.md: Comprehensive documentation
@danielchalef
Copy link
Member

danielchalef commented Dec 17, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Ataxia123
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

danielchalef added a commit that referenced this pull request Dec 17, 2025
…e behavior

Issues fixed:
1. Only serialize attributes for Neo4j, not FalkorDB/Neptune
2. Maintain backward compatibility with existing Neo4j data

Changes:
- Write path: Use elif to specifically target Neo4j only
- Query path: Use COALESCE and return both n.attributes and properties(n)
- Read path: Try JSON string first, fall back to spread properties
- FalkorDB/Neptune: Restore original spread behavior

This ensures:
- New Neo4j nodes: attributes as JSON string (supports nesting)
- Old Neo4j nodes: attributes spread as properties (backward compatible)
- FalkorDB/Neptune: unchanged behavior (no breaking changes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants