Repository navigation
LCORE-5372: Select psycopg2 explicitly for PostgreSQL database engines - #3107
Conversation
SQLAlchemy 2.1 changed the default driver for postgresql:// URLs from psycopg2 to psycopg (version 3). LCS depends on psycopg2-binary, so the implicit driver selection now fails with ModuleNotFoundError for psycopg when initializing a PostgreSQL-backed runtime database. Use postgresql+psycopg2:// to select the existing dependency explicitly and update the database unit test to expect that URL. This fixes startup for PostgreSQL-backed deployments, including those managed by the OpenStack Lightspeed operator, which configures the LCS runtime database to use PostgreSQL. SQLite-backed deployments do not exercise this path. Jira: LCORE-5372
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Set and verify the PostgreSQL driver src/app/database.py, tests/unit/app/test_database.py |
The connection URL specifies the psycopg2 driver. The test expects the updated scheme and checks the remaining URL parameters. |
Estimated code review effort: 1 (Trivial) | ~5 minutes
Change: Bug fix
Suggested reviewers: omertuc, tisnik
Merge Risk: 
Minimal · up to 08c19
-
The PostgreSQL driver change matches the supported runtime dependency and does not introduce an evident merge-blocking risk.
Pre-merge checks: 
7
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Full details: Performance And Algorithmic Complexity
-
Explanation
PASS. The pull request only changes the PostgreSQL SQLAlchemy driver string and its unit-test expectation. It adds no loops, API or database query patterns, list operations, caches, buffers, or endpoint changes. No meaningful performance regression is introduced.
Full details: Security And Secret Handling
-
Explanation
No security violation is introduced. The production diff changes only the SQLAlchemy driver prefix from
postgresql://topostgresql+psycopg2://atsrc/app/database.py:132; it does not add logging, endpoints, responses, secret storage, SQL construction, or filesystem handling. The password interpolation and existing schema operation are unchanged. The test change only updates the expected URL.
Full details: Title check
-
Explanation
The title names the main change: PostgreSQL database engines now select the psycopg2 driver explicitly. The changeset does this by changing the connection URL to postgresql+psycopg2 in src/app/database.py and updating the matching unit test. The title is specific and matches the stated objective of avoiding the implicit psycopg (v3) default in SQLAlchemy 2.1.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
Simplify code
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
|
/ok-to-test |
|
🤖 Finished Retro · ✅ Success · Started 4:59 PM UTC · Completed 5:12 PM UTC Commit: Runtime: pi · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.88 |
Retro: PR #3107 — LCORE-5372: Select psycopg2 explicitly for PostgreSQL database enginesWorkflow quality: Clean. This was a well-executed human-authored PR by @dprince — a 2-line bug fix for SQLAlchemy 2.1's change to the default PostgreSQL driver from No fullsend agent involvement in this PR. No code, review, or fix agents ran. This was entirely a human workflow. There is nothing to assess for review quality, rework rate, or autonomy readiness. Key finding — retro triggered despite config restriction. The Already being addressed. PR #3112 (opened the same day, before this PR merged) switches the retro agent from the derived harness approach to an inline Evidence for existing platform issues:
|
SQLAlchemy 2.1 changed the default driver for postgresql:// URLs from psycopg2 to psycopg (version 3). LCS depends on psycopg2-binary, so the implicit driver selection now fails with ModuleNotFoundError for psycopg when initializing a PostgreSQL-backed runtime database.
Use postgresql+psycopg2:// to select the existing dependency explicitly and update the database unit test to expect that URL.
This fixes startup for PostgreSQL-backed deployments, including those managed by the OpenStack Lightspeed operator, which configures the LCS runtime database to use PostgreSQL. SQLite-backed deployments do not exercise this path.
Jira: LCORE-5372
Summary by CodeRabbit
psycopg2driver. Existing connection settings are unchanged, so this update does not alter the configured database parameters.