fix: addressed an issue where connection strings for databases such as PostgreSQL were wrongly identified as Redis connections #995
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.
This PR addresses two issues related to the auto-detection of database names from connection strings:
1. Incorrect Identification of PostgreSQL Connections as Redis Connections
The issue arose because the regex used for detecting Redis connections was too generic and did not handle all edge cases. Specifically, it failed when the password was optional in certain connection strings. The regex has been updated to be more specific, with added handling for these edge cases. The new regex now correctly handles the following components of a URI:
With this modification, Redis connections are now correctly identified, and PostgreSQL URIs are no longer incorrectly flagged. Additionally, new unit tests have been added to cover these changes.
2. Incorrect Database Name Identification for PostgreSQL URIs
The logic previously only recognized the URI scheme
postgres
for PostgreSQL, which caused issues when the postgresql scheme was used. According to the official PostgreSQL doc, bothpostgres
andpostgresql
are valid URI schemes. The logic has been updated to correctly handle both schemes and identify the database name accurately in all cases.