Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Escape special characters in the Postgres password (#4394)
* Apply fix

Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>

* Add special characters to postgres online store test

Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>

* Fix linting error

Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>

---------

Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>
  • Loading branch information
job-almekinders committed Aug 9, 2024
commit 03954da272d46186c848b5504b0c27192ae7daea
16 changes: 9 additions & 7 deletions sdk/python/feast/infra/utils/postgres/connection_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import psycopg
import pyarrow as pa
from psycopg import AsyncConnection, Connection
from psycopg.conninfo import make_conninfo
from psycopg_pool import AsyncConnectionPool, ConnectionPool

from feast.infra.utils.postgres.postgres_config import PostgreSQLConfig
Expand Down Expand Up @@ -55,13 +56,14 @@ async def _get_connection_pool_async(config: PostgreSQLConfig) -> AsyncConnectio

def _get_conninfo(config: PostgreSQLConfig) -> str:
"""Get the `conninfo` argument required for connection objects."""
return (
f"postgresql://{config.user}"
f":{config.password}"
f"@{config.host}"
f":{int(config.port)}"
f"/{config.database}"
)
psycopg_config = {
"user": config.user,
"password": config.password,
"host": config.host,
"port": int(config.port),
"dbname": config.database,
}
return make_conninfo(conninfo="", **psycopg_config)


def _get_conn_kwargs(config: PostgreSQLConfig) -> Dict[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, project_name: str, **kwargs):
self.container = PostgresContainer(
"postgres:16",
username="root",
password="test",
password="test!@#$%",
dbname="test",
).with_exposed_ports(5432)

Expand All @@ -26,7 +26,7 @@ def create_online_store(self) -> Dict[str, str]:
"host": "localhost",
"type": "postgres",
"user": "root",
"password": "test",
"password": "test!@#$%",
"database": "test",
"port": self.container.get_exposed_port(5432),
}
Expand All @@ -42,7 +42,7 @@ def __init__(self, project_name: str, **kwargs):
self.container = (
DockerContainer("pgvector/pgvector:pg16")
.with_env("POSTGRES_USER", "root")
.with_env("POSTGRES_PASSWORD", "test")
.with_env("POSTGRES_PASSWORD", "test!@#$%")
.with_env("POSTGRES_DB", "test")
.with_exposed_ports(5432)
.with_volume_mapping(
Expand All @@ -65,7 +65,7 @@ def create_online_store(self) -> Dict[str, Any]:
"host": "localhost",
"type": "postgres",
"user": "root",
"password": "test",
"password": "test!@#$%",
"database": "test",
"pgvector_enabled": True,
"vector_len": 2,
Expand Down