From ee6fc45f687562e68bd62a6f1a455c7cbcc9b1c0 Mon Sep 17 00:00:00 2001 From: "Sanghyub.Lee" <31465178+tkdguq05@users.noreply.github.com> Date: Tue, 27 Aug 2024 07:25:59 +0900 Subject: [PATCH] fix: connection_string_parser.py (#3522) * fix: connection_string_parser.py In version 1.0.14, a connection string that includes a port, like the following example, works without any issues: `test_connection_string = 'postgresql://postgres:password!!@pgdatabase.hosts:5432'` However, in version 1.0.15, using this connection string causes an error. "Error building Component PGVector: invalid literal for int() with base 10" This is because 5432, which is the result of parsing the password_url, is being used as the last element in the password_url list. * [autofix.ci] apply automated fixes * Update connection_string_parser.py fix transformed_connection_string = f'{protocol_user}:{encoded_password}@{db_url_name}' * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../base/langflow/utils/connection_string_parser.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/backend/base/langflow/utils/connection_string_parser.py b/src/backend/base/langflow/utils/connection_string_parser.py index f83bdb9ab..a67d2059e 100644 --- a/src/backend/base/langflow/utils/connection_string_parser.py +++ b/src/backend/base/langflow/utils/connection_string_parser.py @@ -2,10 +2,8 @@ from urllib.parse import quote def transform_connection_string(connection_string): - db_url_name = connection_string.split("@")[-1] - password_url = connection_string.split(":")[-1] - password_string = password_url.replace(f"@{db_url_name}", "") + auth_part, db_url_name = connection_string.rsplit("@", 1) + protocol_user, password_string = auth_part.rsplit(":", 1) encoded_password = quote(password_string) - protocol_user = connection_string.split(":")[:-1] - transformed_connection_string = f'{":".join(protocol_user)}:{encoded_password}@{db_url_name}' + transformed_connection_string = f"{protocol_user}:{encoded_password}@{db_url_name}" return transformed_connection_string