Skip to content

Commit eb5407e

Browse files
committed
fix!: PHOENIX_POSTGRES_HOST should not be split (#9087)
1 parent 5222e91 commit eb5407e

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

MIGRATION.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Migrations
22

3+
## v11.x to v12.0.0
4+
5+
### PostgreSQL Connection Environment Variables
6+
7+
**Breaking Change**: Specifying port numbers in `PHOENIX_POSTGRES_HOST` is no longer supported.
8+
9+
**Before**:
10+
```shell
11+
export PHOENIX_POSTGRES_HOST=localhost:5432
12+
```
13+
14+
**After**:
15+
```shell
16+
export PHOENIX_POSTGRES_HOST=localhost
17+
export PHOENIX_POSTGRES_PORT=5432
18+
```
19+
20+
**Impact**: If you were setting `PHOENIX_POSTGRES_HOST` with a port (e.g., `localhost:5432`), you must now separate the host and port into their respective environment variables.
21+
22+
323
## v10.0.0 to v11.0.0
424

525
This release is entirely encapsulated in a set of new tables. Have a nice release!

src/phoenix/config.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,16 +1123,10 @@ def __init__(self, message: Optional[str] = None) -> None:
11231123
super().__init__(message)
11241124

11251125

1126-
# LEGACY: Regex for backward compatibility with host:port parsing in PHOENIX_POSTGRES_HOST
1127-
_HOST_PORT_REGEX = re.compile(r"^[^:]+:\d{1,5}$")
1128-
1129-
11301126
def get_env_postgres_connection_str() -> Optional[str]:
11311127
"""
11321128
Build PostgreSQL connection string from environment variables.
1133-
1134-
LEGACY: Supports host:port parsing in PHOENIX_POSTGRES_HOST for backward compatibility.
1135-
""" # noqa: E501
1129+
"""
11361130
if not (
11371131
(pg_host := getenv(ENV_PHOENIX_POSTGRES_HOST, "").rstrip("/"))
11381132
and (pg_user := getenv(ENV_PHOENIX_POSTGRES_USER))
@@ -1142,10 +1136,6 @@ def get_env_postgres_connection_str() -> Optional[str]:
11421136
pg_port = getenv(ENV_PHOENIX_POSTGRES_PORT)
11431137
pg_db = getenv(ENV_PHOENIX_POSTGRES_DB)
11441138

1145-
if _HOST_PORT_REGEX.match(pg_host): # maintain backward compatibility
1146-
pg_host, parsed_port = pg_host.split(":")
1147-
pg_port = pg_port or parsed_port # use the explicitly set port if provided
1148-
11491139
encoded_user = quote(pg_user)
11501140
encoded_password = quote(pg_password)
11511141
connection_str = f"postgresql://{encoded_user}:{encoded_password}@{pg_host}"

tests/unit/test_config.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,13 @@ def test_minimal_connection_string(self, monkeypatch: pytest.MonkeyPatch) -> Non
5252
expected = f"postgresql://{quote('user')}:{quote('pass')}@localhost"
5353
assert get_env_postgres_connection_str() == expected
5454

55-
def test_full_connection_string_with_port_override(
55+
def test_full_connection_string_with_separate_port(
5656
self, monkeypatch: pytest.MonkeyPatch
5757
) -> None:
58-
"""Test that explicit port overrides port in host string.
59-
60-
LEGACY BEHAVIOR: For backward compatibility, PHOENIX_POSTGRES_HOST can contain
61-
a port (e.g., 'localhost:5432'), which gets parsed and split. However, if
62-
PHOENIX_POSTGRES_PORT is explicitly set, it overrides the port from the host string.
63-
This maintains compatibility with older configurations.
64-
"""
58+
"""Test connection string with all parameters including separate host and port."""
6559
monkeypatch.setenv("PHOENIX_POSTGRES_USER", "user")
6660
monkeypatch.setenv("PHOENIX_POSTGRES_PASSWORD", "pass")
67-
# LEGACY: Host includes port, but explicit port should override it
68-
monkeypatch.setenv("PHOENIX_POSTGRES_HOST", "localhost:5432")
61+
monkeypatch.setenv("PHOENIX_POSTGRES_HOST", "localhost")
6962
monkeypatch.setenv("PHOENIX_POSTGRES_PORT", "9999")
7063
monkeypatch.setenv("PHOENIX_POSTGRES_DB", "mydb")
7164

0 commit comments

Comments
 (0)