Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: addressed an issue where connection strings for databases such as PostgreSQL were wrongly identified as Redis connections #995

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nithinputhenveettil
Copy link
Member

@nithinputhenveettil nithinputhenveettil commented Dec 30, 2024

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:

  • The URI scheme (optional)
  • The username (optional)
  • The optional password (if present, separated by a colon)
  • The hostname
  • The port number

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, both postgres and postgresql are valid URI schemes. The logic has been updated to correctly handle both schemes and identify the database name accurately in all cases.

…s PostgreSQL were wrongly identified as Redis connections
@nithinputhenveettil nithinputhenveettil self-assigned this Dec 30, 2024
@nithinputhenveettil nithinputhenveettil added the tekton_ci Add this label to start running Tekton pipelines label Dec 30, 2024
@nithinputhenveettil nithinputhenveettil marked this pull request as ready for review December 31, 2024 00:55
@nithinputhenveettil nithinputhenveettil requested a review from a team as a code owner December 31, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tekton_ci Add this label to start running Tekton pipelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant