Ensure proper connection handling in reset_database function#33
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the backend template’s generated reset_database() helper to ensure it establishes a Neo4j connection before executing the destructive DETACH DELETE query, addressing failures in make reset where the driver was never initialized.
Changes:
- Wrap the reset Cypher execution in
connect_neo4j()/close_neo4j()with atry/finallyto guarantee cleanup.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…o4j-labs#26) Verifies that reset_database() opens its own connection when _driver is None, closes it via try/finally, preserves pre-existing connections, and uses MATCH (n) DETACH DELETE n. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merged
akkonrad
pushed a commit
to akkonrad/create-context-graph
that referenced
this pull request
May 21, 2026
- Add local-file document connector (PR neo4j-labs#34): deterministic ingestion of Markdown / PDF / HTML / AsciiDoc / Word into :Document → :Section hierarchies with LINKS_TO edges, 8 new optional deps in connectors extra, 1,721-line test_local_file_connector.py. - Fix reset_database() connection lifecycle in generated context_graph_client.py (PR neo4j-labs#33) — opens/closes its own driver when none is pre-existing. - Bump pyproject.toml and npm-wrapper/package.json to 0.10.0. - Refresh CLAUDE.md status, connector count (12 → 13), and test count. - Remove 4 unused datetime/timezone imports flagged by ruff. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
make resetfails with:RuntimeError: Neo4j not connected. Call connect_neo4j() first.
reset_database()in the generatedcontext_graph_client.pycalledexecute_cypher()directly without initializing the driver first.Fix
Wrap the DELETE query with
connect_neo4j()/close_neo4j()in atry/finallyblock — same pattern used elsewhere in the codebase.Change
templates/backend/shared/context_graph_client.py.j2— 4-line changein
reset_database().Fixes #26