Skip to content

ci: use psycopg 3 for the PostgreSQL database tests - #1971

Merged
WilliamBergamin merged 1 commit into
mainfrom
ci/psycopg3-database-tests
Sep 25, 2026
Merged

WilliamBergamin merged 1 commit into
mainfrom
ci/psycopg3-database-tests

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

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 from psycopg2 to psycopg (v3). Our requirements/optional.txt range (SQLAlchemy>=2.0.52,<3) picked it up. The sync PostgreSQL step used a bare URL but requirements/databases.txt only installed psycopg2-binary, so every test errored in setUp with ModuleNotFoundError: No module named 'psycopg'.

This is not a code regression. The failing run is on the same commit as the last green main build, 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_URL now 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 said postgresql+asyncpg:// and is unchanged.

Possible follow-ups, not in this PR:

  • integration_tests/samples/token_rotation/oauth_sqlalchemy.py and oauth_sqlite3.py suggest postgresql:// with pip install psycopg2 in a comment. On SQLAlchemy 2.1 that combination hits this same error.
  • The dependencies list in AGENTS.md doesn't mention requirements/databases.txt.

Testing

Locally, on Python 3.14.7 with SQLAlchemy 2.1.0 against a local PostgreSQL 16:

  • Before (main's requirements and URL): tests/slack_sdk/oauth/installation_store/test_sqlalchemy.py fails 5/5 with the same No module named 'psycopg' as CI.
  • After (psycopg2-binary uninstalled, this branch's databases.txt, CI's env vars): all four PostgreSQL suites pass.
    • Sync, psycopg 3: installation_store 5/5, state_store 3/3.
    • Async, asyncpg: installation_store 5/5, state_store 3/3.

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.sh locally. The rest of the CI matrix covers it.

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

🤖 Generated with Claude Code

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>
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review September 25, 2026 14:59
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner September 25, 2026 14:59
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.15%. Comparing base (77d0a1a) to head (9ab7f2f).
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

@AmyScript AmyScript left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix!

@WilliamBergamin
WilliamBergamin merged commit 3dc7e66 into main Sep 25, 2026
18 checks passed
@WilliamBergamin
WilliamBergamin deleted the ci/psycopg3-database-tests branch September 25, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants