langflow icon indicating copy to clipboard operation
langflow copied to clipboard

feat: sync langflow and lfx versions

Open jordanrfrazier opened this issue 6 months ago • 5 comments

Phase 1 — Langflow↔LFX version contract

Establishes the compatibility guarantee: LFX X.Y.N runs any Flow from Langflow X.Y.M.

  • src/lfx/pyproject.toml — bumped from 0.5.0 → 1.10.0 (now tracks Langflow's major.minor)
  • src/backend/base/pyproject.toml — tightened lfx pin: ~=0.5.0 → ~=1.10.0
  • Makefile patch target — make patch v=X.Y.Z now also updates src/lfx/pyproject.toml and the lfx pin in langflow-base alongside langflow/frontend
  • .github/workflows/release.yml — pre-release lfx constraint now bounds on next minor (<X.(Y+1).dev0) instead of next major
  • scripts/release-lfx.sh — warns when LFX minor doesn't match Langflow minor at release time
  • RELEASE.md — new "LFX Compatibility" section documenting the contract and ~=X.Y.0 pin advice for users

Phase 2 — Flow component upgrade tooling

Ports the frontend's component compatibility algorithm to Python and surfaces it via three CLI entry points.

lfx upgrade <flow.json>

Checks every component node in a flow against the bundled component registry and reports one of four statuses:

  • ok — matches registry exactly
  • outdated_safe — code changed but structure is compatible (auto-upgradeable)
  • outdated_breaking — code changed and outputs/template structure changed (manual fix needed)
  • blocked — component type no longer in registry

--write applies all safe upgrades in-place and writes the file back.

Exit code 0 if clean or safe-only; non-zero if any blocked or breaking components exist.

lfx run <flow.json> --upgrade-flow=safe|check

  • safe — auto-applies safe upgrades in memory before running; aborts if any component is blocked or breaking
  • check — refuses to run if any component is outdated or blocked

lfx serve <flow.json> --upgrade-flow=safe|check

Same semantics as run, applied before uvicorn starts.

New package: lfx.upgrade

  • checker.py — check_flow_compatibility(flow_data, all_types_dict) → CompatibilityReport with per-node NodeStatus
  • applier.py — apply_safe_upgrades(flow_data, registry, report) → dict (always returns a deep copy; never mutates)
  • 27 unit tests covering all status classifications, edge cases, and CLI behavior

Summary by CodeRabbit

Release Notes

  • New Features

    • Added lfx upgrade CLI command to check and safely upgrade flow component compatibility.
    • Added --upgrade-flow option to run and serve commands for automatic compatibility checking and safe upgrades.
  • Documentation

    • Added LFX version compatibility guidance and release procedures in RELEASE.md.
  • Chores

    • Updated LFX dependency to v1.10.0.
    • Added comprehensive test coverage for upgrade functionality and starter flow fixtures.

Review Change Stack

jordanrfrazier avatar May 18 '26 15:05 jordanrfrazier

[!IMPORTANT]

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 288b82ac-4437-433a-8252-47e4e160a8eb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review

Walkthrough

This PR introduces a flow component upgrade system for LFX that checks Langflow flow exports for component compatibility against a bundled registry, applies safe upgrades automatically, and exposes upgrade functionality via a new CLI command and integration into run/serve. Release tooling is updated to maintain version alignment between Langflow and LFX across major.minor versions.

Changes

LFX component upgrade system with release infrastructure

Layer / File(s) Summary
Upgrade data model and compatibility checking
src/lfx/src/lfx/upgrade/checker.py
Defines NodeStatusLiteral, NodeStatus, and CompatibilityReport types; implements build_registry_lookup to flatten components and aliases, check_flow_compatibility to classify nodes by comparing template code against registry and analyzing breaking changes (output equivalence, template keys, input type compatibility) across both top-level and nested flow nodes.
Upgrade package exports
src/lfx/src/lfx/upgrade/__init__.py
Exposes CompatibilityReport, NodeStatus, apply_safe_upgrades, and check_flow_compatibility via __all__ as public upgrade API.
Safe upgrade applier
src/lfx/src/lfx/upgrade/applier.py
Implements apply_safe_upgrades to deep-copy flows, select only nodes marked outdated_safe from a compatibility report, and update their template code from the registry while preserving other data.
CLI upgrade command structure
src/lfx/src/lfx/cli/_upgrade_commands.py, src/lfx/src/lfx/cli/upgrade.py
Defines upgrade CLI command with flow path argument and --write/-w flag; implements registry loading from bundled index, compatibility report printing, safe upgrade application, JSON/envelope parsing with error handling, and non-zero exit for blocked/breaking incompatibilities.
CLI entry point wiring
src/lfx/src/lfx/__main__.py
Imports and registers upgrade command group in Typer app.
Integrate --upgrade-flow into run and serve
src/lfx/src/lfx/cli/_running_commands.py
Adds --upgrade-flow option to both run_command_wrapper and serve_command_wrapper with documented check/safe modes; forwards value to underlying implementations.
Pass upgrade_flow through run CLI
src/lfx/src/lfx/cli/run.py
Adds upgrade_flow parameter to run function and forwards to run_flow via keyword argument.
Serve command upgrade flow integration
src/lfx/src/lfx/cli/commands.py
Refactors serve_command to parse input (flow-json/stdin/.json file) into json_data early; when upgrade_flow is set, runs compatibility check and conditionally applies safe upgrades or fails fast for check mode and blocking/breaking incompatibilities; writes (potentially upgraded) result to temporary file before server loading.
Run flow core upgrade-flow execution
src/lfx/src/lfx/run/base.py
Adds upgrade_flow parameter to run_flow; when set, ensures flow is JSON-sourced, runs check_flow_compatibility, handles upgrade_flow modes (check/safe) with explicit error handling for missing JSON sources and unknown modes.
Package version updates and linting config
src/lfx/pyproject.toml, src/backend/base/pyproject.toml, pyproject.toml
Updates LFX package version 0.5.0 → 1.10.0; updates Langflow base LFX dependency pin ~=0.5.0 → ~=1.10.0; adds TC003 linting rule ignore for upgrade CLI module.
Release infrastructure for version alignment
.github/workflows/release.yml, Makefile, scripts/release-lfx.sh, RELEASE.md
Updates pre-release workflow to increment LFX minor version (not major) for constraint rewriting; updates make patch to synchronize LFX package version and dependency pin; adds minor-version mismatch warning to release-lfx.sh script; documents LFX major.minor compatibility contract and patch release procedures in RELEASE.md.
Test fixtures for upgrade validation
src/lfx/tests/fixtures/starter_flows/MANIFEST.json, src/lfx/tests/fixtures/starter_flows/v1.9.0/basic_prompting.json
Adds MANIFEST.json descriptor for frozen v1.9.0 starter flows; adds basic_prompting.json workflow fixture with ChatInput, Prompt Template, ChatOutput, and Language Model nodes including embedded implementations.
Unit tests for compatibility checker
src/lfx/tests/unit/upgrade/test_checker.py
Tests registry lookup construction, node classification (ok/blocked/outdated_safe/outdated_breaking) across code changes and breaking-change scenarios, report boolean properties, and nested flow node handling.
Unit tests for upgrade applier
src/lfx/tests/unit/upgrade/test_applier.py
Tests apply_safe_upgrades for safe node updates, original flow immutability, skipping of breaking/blocked/ok nodes, and upgrade count reporting.
Unit tests for upgrade CLI command
src/lfx/tests/unit/upgrade/test_upgrade_command.py
Tests lfx upgrade for outdated/clean status reporting, --write file updates, error handling for missing files, and support for Langflow outer-envelope flow exports with nodes under "data" key.
Unit tests for run_flow upgrade option
src/lfx/tests/unit/run/test_base.py
Tests run_flow(..., upgrade_flow=...) for rejection of outdated inline JSON, .json files, outer-envelope exports, Python scripts, unreadable JSON, and unknown upgrade modes.
Integration tests against real starter flows
src/lfx/tests/unit/upgrade/test_upgrade_real_flows.py
Parametrized tests over frozen v1.9.0 fixtures validating checker stability, valid status classification, applier JSON serializability, one-pass convergence, immutability, non-mutation of blocking/breaking nodes, and CI-visible status summary.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

lgtm

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 39.02% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Quality And Coverage ⚠️ Warning Comprehensive tests (36+ functions) with proper async patterns. Unresolved review issues: .py validation missing, TC003 import violation, envelope metadata loss, missing assertions. Add .py file check, fix TC003 import, preserve envelope metadata, add guard assertions for empty fixtures/registry.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: sync langflow and lfx versions' accurately and concisely describes the main change—synchronizing Langflow and LFX versioning systems—which is the central objective across both Phase 1 and Phase 2 of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Coverage For New Implementations ✅ Passed PR includes sufficient test coverage: 42 tests across 4 files covering upgrade module, CLI, run_flow, and real fixtures. All tests substantive with assertions.
Test File Naming And Structure ✅ Passed Test files follow correct patterns: backend test_*.py files, proper pytest structure with fixtures, descriptive names, logical organization, edge cases covered, positive and negative scenarios tested.
Excessive Mock Usage Warning ✅ Passed Minimal and appropriate mocking. Core logic (77% of tests) has zero mocks using test-data builders. Mocks only target external I/O and global singletons. Integration tests verify real behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch sync-langflow-lfx

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 18 '26 15:05 coderabbitai[bot]

✅ Test Coverage Advisor

No source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉

Advisory check only — never blocks merge.

github-actions[bot] avatar May 18 '26 16:05 github-actions[bot]

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 38%
38.82% (48715/125462) 67.96% (6631/9756) 38.61% (1116/2890)

Unit Test Results

Tests Skipped Failures Errors Time
4332 0 :zzz: 0 :x: 0 :fire: 9m 2s :stopwatch:

github-actions[bot] avatar May 18 '26 19:05 github-actions[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 54.49%. Comparing base (4f9e0da) to head (b920134). :warning: Report is 56 commits behind head on release-1.10.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.10.0   #13176      +/-   ##
==================================================
- Coverage           54.61%   54.49%   -0.12%     
==================================================
  Files                2140     2154      +14     
  Lines              199349   201146    +1797     
  Branches            28487    30339    +1852     
==================================================
+ Hits               108877   109623     +746     
- Misses              89296    90347    +1051     
  Partials             1176     1176              
Flag Coverage Δ
backend 60.37% <ø> (+0.69%) :arrow_up:
frontend 54.30% <ø> (-0.36%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/lfx/src/lfx/__main__.py 73.91% <ø> (ø)
src/lfx/src/lfx/cli/_running_commands.py 100.00% <ø> (ø)
src/lfx/src/lfx/cli/commands.py 51.36% <ø> (+0.10%) :arrow_up:
src/lfx/src/lfx/cli/run.py 76.47% <ø> (ø)
src/lfx/src/lfx/run/base.py 80.13% <ø> (ø)

... and 242 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 18 '26 19:05 codecov[bot]

~I will push up a really quick change, we will need to update the base uv.lock~ This is something we will need to do but we can do it after merging back to 1.10.0 and after we merge 1.9.5 in.

Also merge conflicts

Adam-Aghili avatar May 28 '26 15:05 Adam-Aghili