fix: Align dependency checks with cascade delete behavior#52
Conversation
…uery security, and fix chained OPTIONAL MATCH Co-authored-by: spuentesp <112034353+spuentesp@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes three inconsistencies in universe deletion logic to ensure dependency validation matches cascade deletion behavior. The changes prevent silent data loss by ensuring Stories are counted before deletion and improve query reliability by fixing NULL propagation issues.
Key Changes:
- Added Stories to dependency validation checks to match cascade deletion behavior
- Updated query construction pattern from f-strings to explicit concatenation for security consistency
- Fixed Scene/PlotThread matching to anchor on universe node, eliminating NULL propagation when no stories exist
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/data-layer/src/monitor_data/tools/neo4j_tools.py | Added Story counting to dependency validation query, updated error message to include stories, changed update query to use string concatenation, and fixed Scene/PlotThread matching to start from universe node instead of story variable |
| packages/data-layer/tests/test_tools/test_universe_tools.py | Updated test mock data to include stories: 0 and stories: 1 fields to match the new dependency check response structure |
After a thorough review of the code changes, I found no issues to report. The implementation is correct, well-tested, and follows established patterns in the codebase:
- The dependency validation now properly checks for Stories before blocking deletion
- Test mocks correctly reflect the updated query response structure
- The query construction pattern aligns with security best practices documented in
neo4j_list_universes - The Scene/PlotThread matching fix properly addresses NULL propagation by anchoring to the universe node
All changes are consistent, maintainable, and address the issues identified in the PR description.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses three inconsistencies in universe deletion logic identified in code review:
Missing Stories in dependency validation
force=TrueQuery construction pattern inconsistency
neo4j_list_universesChained OPTIONAL MATCH dependency
(u)-[:HAS_STORY]->(:Story)-[:HAS_SCENE]->(scene:Scene)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.