Skip to content

fix: correct deprecated model settings behavior#14048

Open
erichare wants to merge 3 commits into
release-1.11.0from
fix/deprecated-model-settings-release-1.11.0
Open

fix: correct deprecated model settings behavior#14048
erichare wants to merge 3 commits into
release-1.11.0from
fix/deprecated-model-settings-release-1.11.0

Conversation

@erichare

@erichare erichare commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Release-1.11.0 companion to #14047.

Summary

  • disable model-provider switches for deprecated and unsupported models
  • reject API attempts to persist those models as explicitly enabled
  • limit age-based auto-deprecation to language models so embeddings do not become deprecated solely because they cross the 900-day threshold

Root cause

The settings UI allowed deprecated models to enter its optimistic toggle queue, and the update endpoint accepted and persisted that state. A later GET /enabled_models always returned deprecated models as disabled, so the next refetch appeared to undo the user's toggle.

Separately, the models.dev fallback marks catalog entries older than 900 days as deprecated. That heuristic also applied to embeddings. The OpenAI text-embedding-3-* models reached that threshold in July 2026 even though age alone is not a reliable deprecation signal for embedding models.

Explicit catalog deprecations remain unchanged, including provider-specific embedding models that are known to be unavailable.

Validation

  • uv run pytest tests/unit/base/models/test_models_dev_catalog.py -q (23 passed)
  • uv run pytest src/backend/tests/unit/api/v1/test_models_enabled_providers.py -k cannot_enable_deprecated_model -q (1 passed)
  • npm test -- src/modals/modelProviderModal/__tests__/ModelSelection.test.tsx --runInBand (31 passed)
  • focused Ruff and Biome checks
  • pre-commit hooks
  • live models.dev smoke test confirms all three OpenAI embedding models remain non-deprecated

Summary by CodeRabbit

  • New Features

    • Prevented deprecated and unsupported models from being enabled through the model selection interface.
    • Added clear validation errors when unavailable models are requested through the API.
    • Deprecated model entries now remain visibly identified while their enable controls are disabled.
  • Bug Fixes

    • Automatic age-based deprecation now applies only to language models; embedding models are excluded.
    • Existing static deprecation labels for embedding models are preserved.

@erichare erichare added the bug Something isn't working label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Model availability enforcement

Layer / File(s) Summary
Language-model deprecation semantics
src/lfx/src/lfx/base/models/models_dev_catalog.py, src/lfx/tests/unit/base/models/test_models_dev_catalog.py
Documentation and tests clarify that age-based auto-deprecation applies to language models, while embedding models remain exempt and static flags are preserved.
Backend enablement validation
src/backend/base/langflow/api/v1/models.py, src/backend/tests/unit/api/v1/test_models_enabled_providers.py, src/backend/tests/unit/api/v1/test_variable.py
The API rejects requests enabling deprecated or unsupported models and tests the rejection and credential-cleanup behavior.
Frontend unavailable-model controls
src/frontend/src/modals/modelProviderModal/components/ModelSelection.tsx, src/frontend/src/modals/modelProviderModal/__tests__/ModelSelection.test.tsx
Model toggles are disabled for deprecated or unsupported models, with tests verifying disabled interaction behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ModelSelection
  participant update_enabled_models
  participant UnifiedCatalog
  Client->>ModelSelection: Select model
  ModelSelection->>UnifiedCatalog: Read model metadata
  UnifiedCatalog-->>ModelSelection: Return availability flags
  ModelSelection-->>Client: Disable unavailable model toggle
  Client->>update_enabled_models: Submit enabled model update
  update_enabled_models->>UnifiedCatalog: Check model availability
  UnifiedCatalog-->>update_enabled_models: Return unavailable reason
  update_enabled_models-->>Client: Return HTTP 400
Loading

Suggested reviewers: himavarshavs, lucaseduoli, edwinjosechittilappilly, deon-sanchez

🚥 Pre-merge checks | ✅ 9
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly reflects the main change around deprecated model settings behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 Added targeted regression/unit tests for deprecated-model rejection, disabled toggles, credential cleanup, and age-based deprecation; filenames follow project conventions.
Test Quality And Coverage ✅ Passed Tests cover the new backend 400 path, a successful enabled-model update/cleanup path, frontend disabled-toggle behavior, and catalog auto-deprecation; async pytest/jest patterns are used.
Test File Naming And Structure ✅ Passed Backend tests use pytest test_*.py; frontend uses ModelSelection.test.tsx with Jest/RTL; test names and coverage are descriptive and structured.
Excessive Mock Usage Warning ✅ Passed Mocks are scoped to external API/hook/network dependencies; the tests still exercise real endpoints and UI behavior, so no excessive-mocking warning.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deprecated-model-settings-release-1.11.0

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.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Test Coverage Advisor

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

Advisory check only — never blocks merge.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 29.16667% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.55%. Comparing base (6450159) to head (a704b17).
⚠️ Report is 4 commits behind head on release-1.11.0.

Files with missing lines Patch % Lines
src/backend/base/langflow/api/v1/models.py 0.00% 17 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.11.0   #14048      +/-   ##
==================================================
+ Coverage           60.16%   60.55%   +0.39%     
==================================================
  Files                2333     2342       +9     
  Lines              228353   229953    +1600     
  Branches            32038    32275     +237     
==================================================
+ Hits               137386   139250    +1864     
+ Misses              89351    89041     -310     
- Partials             1616     1662      +46     
Flag Coverage Δ
backend 67.36% <0.00%> (+0.45%) ⬆️
frontend 59.36% <100.00%> (+0.33%) ⬆️
lfx 58.13% <100.00%> (+0.56%) ⬆️

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

Files with missing lines Coverage Δ
...s/modelProviderModal/components/ModelSelection.tsx 99.64% <100.00%> (+0.38%) ⬆️
src/lfx/src/lfx/base/models/models_dev_catalog.py 86.59% <100.00%> (+0.15%) ⬆️
src/backend/base/langflow/api/v1/models.py 54.98% <0.00%> (+8.93%) ⬆️

... and 167 files with indirect coverage changes

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

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 46%
46.01% (63926/138923) 70.03% (8778/12533) 44.16% (1441/3263)

Unit Test Results

Tests Skipped Failures Errors Time
5302 0 💤 0 ❌ 0 🔥 16m 27s ⏱️

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 13, 2026
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jul 13, 2026

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
src/backend/tests/unit/api/v1/test_models_enabled_providers.py (1)

368-380: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for not_supported model rejection.

The test covers the deprecated rejection path but not the not_supported branch (line 848-849 in models.py). The elif creates a distinct code path with a different error message ("Cannot enable not supported model: ...") that should be verified. As per coding guidelines, API endpoint tests should verify both success and error responses, and test coverage should cover the new or changed behavior.

🧪 Suggested test for not_supported model rejection
 `@pytest.mark.usefixtures`("active_user")
 async def test_cannot_enable_deprecated_model(client: AsyncClient, logged_in_headers):
     """Deprecated models cannot be persisted as explicitly enabled."""
     response = await client.post(
         "api/v1/models/enabled_models",
         json=[{"provider": "OpenAI", "model_id": "gpt-3.5-turbo", "enabled": True}],
         headers=logged_in_headers,
     )

     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert response.json()["detail"] == "Cannot enable deprecated model: gpt-3.5-turbo"
+
+
+@pytest.mark.usefixtures("active_user")
+async def test_cannot_enable_not_supported_model(client: AsyncClient, logged_in_headers):
+    """Not-supported models cannot be persisted as explicitly enabled."""
+    # Use a model that is marked not_supported in the catalog
+    response = await client.post(
+        "api/v1/models/enabled_models",
+        json=[{"provider": "<Provider>", "model_id": "<not_supported_model>", "enabled": True}],
+        headers=logged_in_headers,
+    )
+
+    assert response.status_code == status.HTTP_400_BAD_REQUEST
+    assert response.json()["detail"] == "Cannot enable not supported model: <not_supported_model>"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/backend/tests/unit/api/v1/test_models_enabled_providers.py` around lines
368 - 380, Add a unit test alongside test_cannot_enable_deprecated_model
covering an explicitly enabled model marked not_supported. Post the same
enabled-model payload through the endpoint with logged_in_headers, assert HTTP
400, and verify the response detail is exactly "Cannot enable not supported
model: ..." for the chosen model.

Source: Coding guidelines

src/frontend/src/modals/modelProviderModal/__tests__/ModelSelection.test.tsx (1)

535-553: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for not_supported model toggle.

The test verifies the deprecated toggle is disabled but does not cover the not_supported condition added at line 162 of ModelSelection.tsx. As per coding guidelines, frontend tests should verify the new or changed behavior rather than acting as placeholders, and the not_supported disabling is part of this PR's changes.

🧪 Suggested test for not_supported model toggle
     it("should not allow deprecated models to be enabled", async () => {
       const user = userEvent.setup();
       const onModelToggle = jest.fn();
       render(
         <ModelSelection
           {...defaultProps}
           availableModels={withDeprecated}
           modelType="llm"
           onModelToggle={onModelToggle}
         />,
       );

       await user.click(screen.getByTestId("llm-deprecated-summary"));
       const deprecatedToggle = screen.getByTestId("llm-toggle-gpt-old");
       expect(deprecatedToggle).toBeDisabled();

       await user.click(deprecatedToggle);
       expect(onModelToggle).not.toHaveBeenCalled();
     });
+
+    it("should not allow not_supported models to be enabled", async () => {
+      const user = userEvent.setup();
+      const onModelToggle = jest.fn();
+      const withNotSupported = [
+        ...defaultModels,
+        { model_name: "gpt-unsupported", metadata: { model_type: "llm", not_supported: true } },
+      ];
+      render(
+        <ModelSelection
+          {...defaultProps}
+          availableModels={withNotSupported}
+          modelType="llm"
+          onModelToggle={onModelToggle}
+        />,
+      );
+
+      // not_supported models may not appear in the deprecated disclosure;
+      // adjust the selector based on how they are rendered in the UI.
+      const unsupportedToggle = screen.getByTestId("llm-toggle-gpt-unsupported");
+      expect(unsupportedToggle).toBeDisabled();
+
+      await user.click(unsupportedToggle);
+      expect(onModelToggle).not.toHaveBeenCalled();
+    });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/frontend/src/modals/modelProviderModal/__tests__/ModelSelection.test.tsx`
around lines 535 - 553, Extend the ModelSelection tests around the existing
deprecated-model toggle case to cover a model marked not_supported. Render the
component with that model in availableModels, open the appropriate summary,
assert its toggle is disabled, and verify clicking it does not call
onModelToggle, matching the behavior implemented in ModelSelection.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/backend/tests/unit/api/v1/test_models_enabled_providers.py`:
- Around line 368-380: Add a unit test alongside
test_cannot_enable_deprecated_model covering an explicitly enabled model marked
not_supported. Post the same enabled-model payload through the endpoint with
logged_in_headers, assert HTTP 400, and verify the response detail is exactly
"Cannot enable not supported model: ..." for the chosen model.

In
`@src/frontend/src/modals/modelProviderModal/__tests__/ModelSelection.test.tsx`:
- Around line 535-553: Extend the ModelSelection tests around the existing
deprecated-model toggle case to cover a model marked not_supported. Render the
component with that model in availableModels, open the appropriate summary,
assert its toggle is disabled, and verify clicking it does not call
onModelToggle, matching the behavior implemented in ModelSelection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc659f04-dc2f-403c-a0ea-32fb675ea0ab

📥 Commits

Reviewing files that changed from the base of the PR and between 5f1bb6d and a704b17.

📒 Files selected for processing (7)
  • src/backend/base/langflow/api/v1/models.py
  • src/backend/tests/unit/api/v1/test_models_enabled_providers.py
  • src/backend/tests/unit/api/v1/test_variable.py
  • src/frontend/src/modals/modelProviderModal/__tests__/ModelSelection.test.tsx
  • src/frontend/src/modals/modelProviderModal/components/ModelSelection.tsx
  • src/lfx/src/lfx/base/models/models_dev_catalog.py
  • src/lfx/tests/unit/base/models/test_models_dev_catalog.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant