Skip to content

fix(neo4j): route database_ to connection kwarg (#1481) - #1780

Closed
gauravch-code wants to merge 1 commit into
getzep:mainfrom
gauravch-code:fix/neo4j-driver-database-param
Closed

gauravch-code wants to merge 1 commit into
getzep:mainfrom
gauravch-code:fix/neo4j-driver-database-param

Conversation

@gauravch-code

@gauravch-code gauravch-code commented Aug 18, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1481.

Neo4jDriver.execute_query was placing database_ inside parameters_ (the Cypher variables dict) rather than passing it as a driver-level kwarg to Neo4j's execute_query. As a result, database_ was treated as an unused Cypher parameter and silently ignored — every query routed to the connection's home database regardless of the database value passed to Neo4jDriver(...). Only writes that went through session(database=...) explicitly (e.g. transaction()) hit the intended database.

Fix

Route database_ to the driver-level kwarg on AsyncDriver.execute_query. Accept it from either params or kwargs for backwards compatibility so callers that historically stuck it in params keep working.

database = (
    params.pop('database_', None)
    or kwargs.pop('database_', None)
    or self._database
)
result = await self.client.execute_query(
    cypher_query_,
    parameters_=params,
    database_=database,
    **kwargs,
)

Tests

New tests/driver/test_neo4j_driver.py — 7 tests, mock-only (no live Neo4j required):

  • test_configured_database_is_passed_as_connection_kwarg — the core regression for [BUG] Database Parameter Not Honored in Neo4jDriver.execute_query() #1481
  • test_default_database_is_used_when_none_configured
  • test_explicit_database_kwarg_overrides_configured_default
  • test_database_nested_in_params_is_promoted_to_connection_kwarg — backwards compat
  • test_routing_kwarg_is_forwarded_at_connection_level
  • test_extra_kwargs_are_forwarded
  • test_provider

Added the new file to the database-integration-tests job in .github/workflows/unit_tests.yml, mirroring the existing test_falkordb_driver.py entry.

Verified locally

  • ruff format + ruff check — clean
  • pyright graphiti_core/driver/neo4j_driver.py — 0 errors, 0 warnings
  • pytest tests/driver/test_falkordb_driver.py tests/driver/test_neo4j_driver.py — 32 passed, 1 skipped
  • Full unit suite with CI's ignore list — 366 passed, 11 skipped, no regressions

Test plan

  • Regression test fails on unmodified main (asserts database_ is a top-level kwarg; observed {'parameters_': {'database_': 'mydb'}} on main)
  • Regression test passes after fix
  • Full unit suite passes
  • ruff + pyright clean

Neo4jDriver.execute_query was placing `database_` inside `parameters_`
(the Cypher variables dict) rather than passing it as a top-level kwarg
on Neo4j's execute_query. As a result, `database_` was treated as an
unused Cypher parameter and silently ignored, and every query routed
to the connection's home database regardless of the `database` value
passed to `Neo4jDriver(...)`.

Route `database_` to the driver-level kwarg, while still honoring
callers that historically passed it inside `params` for backwards
compatibility.

Add tests/driver/test_neo4j_driver.py with regression coverage:

- Configured database is forwarded as a connection kwarg
- Default database is used when none is configured
- Explicit `database_` kwarg overrides the driver default
- `database_` nested in `params` is promoted to the connection kwarg
- Existing `routing_` and Cypher-parameter kwargs still pass through

Include the new test file in the database-integration-tests job of
unit_tests.yml alongside test_falkordb_driver.py.

Closes getzep#1481
@zep-cla-assistant

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. For privacy information, see our Privacy Notice. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: example@example.com

or

I have read the CLA Document and I hereby sign the CLA behalf of my company, e-mail: example@example.com

Signature is valid for 6 months.


This bot will be retriggered when the Contributor License Agreement comment has been provided. Posted by the CLA Assistant Lite bot.

@gauravch-code

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: gaurav.pvt25@gmail.com

@mehulp93

mehulp93 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for contributing to Graphiti and for diagnosing this.

We’ve shipped the fix in graphiti-core v0.30.1 and MCP v1.1.0: database_ is now passed as a Neo4j connection argument, and the MCP server honors NEO4J_DATABASE. We’re closing this PR in favor of that release.

Please note:

  • If your server’s home database is not named neo4j and you don’t pass database to the driver, queries now target neo4j instead of your home database — pass your database name explicitly to keep the old behavior.
  • If you configured a custom database, reads now correctly target it. Data previously written via execute_query may reside in your home database and may need to be migrated.

@mehulp93 mehulp93 closed this Sep 1, 2026
@zep-cla-assistant zep-cla-assistant Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Database Parameter Not Honored in Neo4jDriver.execute_query()

2 participants