Skip to content

fix(ci): install langflow with [postgresql] extra in migration-test - #234

Merged
lice-reis merged 1 commit into
mainfrom
fix/migration-test-postgresql-extra
May 18, 2026
Merged

fix(ci): install langflow with [postgresql] extra in migration-test#234
lice-reis merged 1 commit into
mainfrom
fix/migration-test-postgresql-extra

Conversation

@lice-reis

Copy link
Copy Markdown
Collaborator

Summary

  • migration-test.yml started failing on the Wait for Langflow latest step after PR #230 replaced the Docker-based setup with uv pip install langflow.
  • Root cause: the official Docker image bundles psycopg2-binary, but the PyPI package declares psycopg2 only under the postgresql extra (sqlalchemy[postgresql-psycopg2binary]). Without the extra, Langflow crashes on startup with ModuleNotFoundError: No module named 'psycopg2' inside check_postgresql_version_sync whenever LANGFLOW_DATABASE_URL starts with postgresql://.
  • Fix: add [postgresql] to both install steps (latest and nightly). No code or migration logic changed.

Investigation findings (for the record)

Question Answer
Is the migration latest → nightly broken with Postgres? No — confirmed working via isolated Podman test (witness flow preserved, UUID matches, alembic ran cleanly, no UniqueViolation).
Did Langflow 1.9.3 introduce a regression? No — Langflow 1.9.2 fails with the exact same ModuleNotFoundError at the same line. The function check_postgresql_version_sync is present and identical in both versions. PyPI metadata for psycopg has been identical since 1.9.0.
Why did the workflow pass before the refactor? Earlier runs used docker pull langflowai/langflow:latest, which has psycopg2-binary baked in.

Test plan

  • Validated locally in a Podman container running python:3.12-slim:
    • pip install uvuv venv .venvuv pip install "langflow[postgresql]"uv run langflow run
    • Confirmed import psycopg2 succeeds (psycopg2 2.9.12)
    • Langflow 1.9.3 booted, served /api/v1/version and loaded 32 starter projects against a fresh Postgres 16
  • Re-run migration-test.yml after merge — should now pass the full latest → nightly flow

🤖 Generated with Claude Code

The refactor that switched from Docker pulls to `uv pip install langflow`
dropped the PostgreSQL driver. The official Docker image bundles
psycopg2-binary, but the PyPI package declares psycopg2 only under the
`postgresql` extra (`sqlalchemy[postgresql-psycopg2binary]`). Without
the extra, Langflow crashes on startup with
`ModuleNotFoundError: No module named 'psycopg2'` inside
`check_postgresql_version_sync` for any `postgresql://` database URL.

This behavior is identical in 1.9.2 and 1.9.3 — confirmed empirically
via isolated Podman containers — so it is not a Langflow regression,
just the documented packaging contract.

Fix: add `[postgresql]` to both install steps (latest and nightly).
Validated locally with `uv pip install "langflow[postgresql]"` against
a fresh Postgres 16 container: Langflow 1.9.3 boots cleanly and serves
the API.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the migration-test GitHub Actions workflow to install Langflow with the postgresql extra so the workflow can start Langflow successfully when LANGFLOW_DATABASE_URL uses the postgresql:// scheme (restoring parity with the official Docker image, which includes Postgres driver deps).

Changes:

  • Install langflow[postgresql] for the “latest” phase.
  • Install langflow[postgresql]==$NIGHTLY_VERSION for the “nightly” phase.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lice-reis
lice-reis merged commit 23eddb5 into main May 18, 2026
6 checks passed
lice-reis added a commit that referenced this pull request May 18, 2026
…244)

* fix(ci): expose OPENAI_API_KEY to Langflow process for env-based credential auto-import

The setup_latest.py helper creates the OPENAI_API_KEY Global Variable via
POST /api/v1/variables/ AFTER Langflow is already running. The Simple Agent
starter project, however, resolves its credential binding at startup —
so the variable created post-startup is not picked up, and flow execution
fails with "Missing credentials".

Langflow has built-in support for promoting OS environment variables to
Credential-typed Global Variables on startup. `OPENAI_API_KEY` is in the
default auto-import list, so simply exposing it as an env var on the
Start step makes the variable available at the right time, encrypted with
LANGFLOW_SECRET_KEY in the DB just like any UI-created credential.

Reference: https://docs.langflow.org/configuration-global-variables
("Langflow automatically detects standard keys like OPENAI_API_KEY from
constants.py without requiring explicit declaration in
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT.")

The redundant POST /api/v1/variables/ call in setup_latest.py is left in
place — it's now a no-op or a warning, but it doesn't fail the run. Can
be cleaned up in a follow-up.

Closes the failure mode exposed by run 26047300330 (which itself was
unblocked by the [postgresql]-extra fix in #234).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(ci): fail fast when OPENAI_API_KEY secret is missing

Address Copilot review feedback on #244. When the OPENAI_API_KEY repo
secret is not configured, `\${{ secrets.OPENAI_API_KEY }}` resolves to
an empty string rather than being unset. Langflow's env-based credential
auto-import skips empty values, so the workflow only fails 5+ minutes
later at the flow-execution step with a misleading "Missing credentials"
error.

Guard with an early step that aborts immediately with a clear message if
the secret is empty, sparing the install/migration time on a known-bad
configuration.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@Victor-w-Madeira
Victor-w-Madeira deleted the fix/migration-test-postgresql-extra branch May 18, 2026 19:21
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