ci: use psycopg 3 for the PostgreSQL database tests - #1971
Merged
Merged
Conversation
SQLAlchemy 2.1.0 (released 2026-09-24) changed the default driver for bare postgresql:// URLs from psycopg2 to psycopg (v3). The Database Unit Tests job used a bare URL but only installed psycopg2-binary, so create_engine failed with "No module named 'psycopg'" on every run: https://github.com/slackapi/python-slack-sdk/actions/runs/36079341012 Install psycopg[binary] in place of psycopg2-binary and name the driver explicitly in TEST_DATABASE_URL, the form SQLAlchemy's 2.1 migration guide recommends, so the job no longer depends on SQLAlchemy's default. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1971 +/- ##
=======================================
Coverage 84.15% 84.15%
=======================================
Files 118 118
Lines 13566 13566
=======================================
Hits 11416 11416
Misses 2150 2150 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the nightly Database Unit Tests regression on
main(https://github.com/slackapi/python-slack-sdk/actions/runs/36079341012/job/107897544636).SQLAlchemy 2.1.0 (released 2026-09-24) changed the default PostgreSQL driver for bare
postgresql://URLs frompsycopg2topsycopg(v3). Ourrequirements/optional.txtrange (SQLAlchemy>=2.0.52,<3) picked it up. The sync PostgreSQL step used a bare URL butrequirements/databases.txtonly installedpsycopg2-binary, so every test errored insetUpwithModuleNotFoundError: No module named 'psycopg'.This is not a code regression. The failing run is on the same commit as the last green
mainbuild, and the SQLite store tests already pass on SQLAlchemy 2.1.0 in the unit test matrix.Changes:
requirements/databases.txt:psycopg2-binary->psycopg[binary]>=3.3.6,<4.ci-build.yml:TEST_DATABASE_URLnow names the driver explicitly (postgresql+psycopg://), the form SQLAlchemy's migration guide recommends. The job no longer depends on SQLAlchemy's default, and the explicit URL works on 2.0 and 2.1. The async URL already saidpostgresql+asyncpg://and is unchanged.Possible follow-ups, not in this PR:
integration_tests/samples/token_rotation/oauth_sqlalchemy.pyandoauth_sqlite3.pysuggestpostgresql://withpip install psycopg2in a comment. On SQLAlchemy 2.1 that combination hits this same error.AGENTS.mddoesn't mentionrequirements/databases.txt.Testing
Locally, on Python 3.14.7 with SQLAlchemy 2.1.0 against a local PostgreSQL 16:
main's requirements and URL):tests/slack_sdk/oauth/installation_store/test_sqlalchemy.pyfails 5/5 with the sameNo module named 'psycopg'as CI.psycopg2-binaryuninstalled, this branch'sdatabases.txt, CI's env vars): all four PostgreSQL suites pass.The state_store sync tests and both async suites never ran in the failing job (the step stopped at the first failure). The Database Unit Tests job on this PR is the check that the whole job is green again.
No Python code changed, so I didn't run
./scripts/run_validation.shlocally. The rest of the CI matrix covers it.Category
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.🤖 Generated with Claude Code