Skip to content

Commit 66ff306

Browse files
authored
Raise ConfigurationError on direct driver with routing context (#1178)
Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct driver ("bolt[+s[sc]]://" scheme). A deprecation warning was already being emitted in such case.
1 parent cb6c0a3 commit 66ff306

File tree

5 files changed

+18
-31
lines changed

5 files changed

+18
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
7878
- `ERROR_REWRITE_MAP`
7979
- `client_errors`
8080
- `transient_errors`
81-
81+
- Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct
82+
driver ("bolt[+s[sc]]://" scheme).
8283

8384
## Version 5.28
8485
- Since the types of `Relationship`s are tied to the `Graph` object they belong to, fixing `pickle` support for graph types means that `Relationship`s with the same name will have a different type after `deepcopy`ing or pickling and unpickling them or their graph.

src/neo4j/_async/driver.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,11 @@ def driver(
277277
assert driver_type in {DRIVER_BOLT, DRIVER_NEO4J}
278278
if driver_type == DRIVER_BOLT:
279279
if parse_routing_context(parsed.query):
280-
deprecation_warn(
281-
'Creating a direct driver ("bolt://" scheme) with '
282-
"routing context (URI parameters) is deprecated. They "
283-
"will be ignored. This will raise an error in a "
284-
f'future release. Given URI "{uri}"',
285-
stack_level=2,
280+
raise ConfigurationError(
281+
"Routing context (URI query parameters) are not "
282+
"supported by direct drivers "
283+
f'("bolt[+s[sc]]://" scheme). Given URI: {uri!r}.'
286284
)
287-
# TODO: 6.0 - raise instead of warning
288-
# raise ValueError(
289-
# 'Routing parameters are not supported with scheme '
290-
# '"bolt". Given URI "{}".'.format(uri)
291-
# )
292285
return cls.bolt_driver(parsed.netloc, **config)
293286
# else driver_type == DRIVER_NEO4J
294287
routing_context = parse_routing_context(parsed.query)

src/neo4j/_sync/driver.py

Lines changed: 4 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/async_/test_driver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ async def test_direct_driver_constructor(
9898
):
9999
uri = protocol + host + port + params
100100
if params:
101-
with pytest.warns(DeprecationWarning, match="routing context"):
102-
driver = AsyncGraphDatabase.driver(uri, auth=auth_token)
101+
with pytest.raises(ConfigurationError, match="Routing context"):
102+
AsyncGraphDatabase.driver(uri, auth=auth_token)
103103
else:
104104
driver = AsyncGraphDatabase.driver(uri, auth=auth_token)
105-
assert isinstance(driver, AsyncBoltDriver)
106-
await driver.close()
105+
await driver.close()
106+
assert isinstance(driver, AsyncBoltDriver)
107107

108108

109109
@pytest.mark.parametrize(

tests/unit/sync/test_driver.py

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)