Fix AttributeError when pool is None in Bolt3 error handling #1267
+4
−2
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.
Fix AttributeError when pool is None in Bolt3 error handling
Problem
When a Neo4jError is raised in Bolt3 connections, the error handler attempts to call self.pool.on_neo4j_error() without checking if self.pool exists. This causes an AttributeError when the connection pool is None or not available.
Solution
Added a null check for self.pool before calling on_neo4j_error(), consistent with the existing error handling pattern used for ServiceUnavailable, DatabaseUnavailable, NotALeader, and ForbiddenOnReadOnlyDatabase exceptions in the same method.
Changes
This prevents crashes when handling Neo4j errors in scenarios where the connection pool is not initialized or has been cleared.
Note:
I am a first-time contributor and have just signed the CLA