fix(graph): preserve existing node ntype and props in add_node - #272
codeforstartups merged 1 commit into
Conversation
Closes codeforstartups#271. - Update GraphStore.add_node to use if_not_exists for ntype and props. - Prevent add_edge and link_docs placeholder node initialization from erasing pre-existing entity metadata. - Add unit tests verifying node metadata preservation across edge additions, doc linkages, and partial updates.
|
Reviewed and verified — this is a real data-loss fix, nicely done. 🎯
The two new tests ( |
Description
Fixes a critical data-loss bug in the Knowledge Graph layer where calling
add_edge()orlink_docs()inadvertently erased pre-existing nodentypeandpropsmetadata in DynamoDB.Related issue
Fixes #271
Changes
src/dynavec/graph.py: UpdatedGraphStore.add_node()to conditionally setntypeandpropsusing DynamoDBif_not_existsclauses instead of unconditionally replacing them withNone/{}.tests/test_graph_properties.py: Added unit tests verifying:add_edge()andlink_docs()preserve existing entityntypeandprops.add_node()calls preserve unspecified node attributes.Testing
pytest tests/test_graph_properties.py tests/test_graph_delete.py tests/test_graph_export.py— 32 passed)Checklist