diff --git a/backend/packages/harness/deerflow/config/database_config.py b/backend/packages/harness/deerflow/config/database_config.py index 37cfd579d..bcd869069 100644 --- a/backend/packages/harness/deerflow/config/database_config.py +++ b/backend/packages/harness/deerflow/config/database_config.py @@ -98,5 +98,8 @@ class DatabaseConfig(BaseModel): url = self.postgres_url if url.startswith("postgresql://"): url = url.replace("postgresql://", "postgresql+asyncpg://", 1) + elif url.startswith("postgres://"): + # libpq's short alias: accepted by the psycopg checkpointer, but not a SQLAlchemy dialect. + url = url.replace("postgres://", "postgresql+asyncpg://", 1) return url raise ValueError(f"No SQLAlchemy URL for backend={self.backend!r}") diff --git a/backend/tests/test_persistence_scaffold.py b/backend/tests/test_persistence_scaffold.py index baba88c4b..ba460b9af 100644 --- a/backend/tests/test_persistence_scaffold.py +++ b/backend/tests/test_persistence_scaffold.py @@ -49,6 +49,15 @@ class TestDatabaseConfig: assert url.startswith("postgresql+asyncpg://") assert "u:p@h:5432/db" in url + def test_app_sqlalchemy_url_postgres_short_scheme(self): + c = DatabaseConfig( + backend="postgres", + postgres_url="postgres://u:p@h:5432/db", + ) + url = c.app_sqlalchemy_url + assert url.startswith("postgresql+asyncpg://") + assert "u:p@h:5432/db" in url + def test_app_sqlalchemy_url_postgres_already_asyncpg(self): c = DatabaseConfig( backend="postgres",