Skip to content

Commit 82e43a6

Browse files
fix(postgres): resolve 3 CI failures in PR QA Gate
1. keyword_ops.py: Use CAST(:metadata AS jsonb) instead of :metadata::jsonb — the :: cast syntax conflicts with SQLAlchemy's :name bind parameter parsing, producing invalid SQL in PostgreSQL. 2. connection.py: Clamp pool.overflow() with max(0, ...) in get_pool_status() — QueuePool.overflow() can return negative values when connections are below pool_size. 3. test_storage_config.py: Add monkeypatch.delenv("DATABASE_URL") to prevent CI's DATABASE_URL environment variable from making the postgres-no-config warning test pass incorrectly. Fixes PR QA Gate run #22010406320. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e213b25 commit 82e43a6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

agent-brain-server/agent_brain_server/storage/postgres/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,6 @@ async def get_pool_status(self) -> dict[str, Any]:
193193
"pool_size": pool.size(),
194194
"checked_in": pool.checkedin(),
195195
"checked_out": pool.checkedout(),
196-
"overflow": pool.overflow(),
197-
"total": pool.size() + pool.overflow(),
196+
"overflow": max(0, pool.overflow()),
197+
"total": pool.size() + max(0, pool.overflow()),
198198
}

agent-brain-server/agent_brain_server/storage/postgres/keyword_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def upsert_with_tsvector(
8282
INSERT INTO documents
8383
(chunk_id, document_text, metadata, tsv)
8484
VALUES (
85-
:chunk_id, :document_text, :metadata::jsonb,
85+
:chunk_id, :document_text, CAST(:metadata AS jsonb),
8686
setweight(to_tsvector(
8787
:language, COALESCE(:title, '')
8888
), 'A') ||

agent-brain-server/tests/unit/config/test_storage_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,13 @@ def test_provider_settings_yaml_roundtrip_postgres() -> None:
135135
assert settings.storage.postgres["port"] == 5432
136136

137137

138-
def test_validate_provider_config_postgres_no_config_warning() -> None:
138+
def test_validate_provider_config_postgres_no_config_warning(
139+
monkeypatch: pytest.MonkeyPatch,
140+
) -> None:
139141
"""Test validate_provider_config warns when postgres backend has no config."""
142+
# Ensure DATABASE_URL is not set (CI sets it for postgres tests)
143+
monkeypatch.delenv("DATABASE_URL", raising=False)
144+
140145
settings = ProviderSettings(
141146
storage=StorageConfig(backend="postgres", postgres={}),
142147
)

0 commit comments

Comments
 (0)