Skip to content

feat: deployments api surface#12041

Draft
HzaRashid wants to merge 5 commits intomainfrom
deployments-api-surface
Draft

feat: deployments api surface#12041
HzaRashid wants to merge 5 commits intomainfrom
deployments-api-surface

Conversation

@HzaRashid
Copy link
Collaborator

@HzaRashid HzaRashid commented Mar 4, 2026

introduce the deployments api and schemas. No endpoints are implemented.

Moves all schemas into a dedicated folder. Creates a dedicated schemas file for the deployments api.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added deployment management API endpoints for managing deployment providers, creating and updating deployments, and managing deployment configurations
    • Added deployment execution endpoints for running and monitoring deployments
    • Added support for redeploying and duplicating existing deployments
    • Added deployment status tracking capabilities

@HzaRashid HzaRashid changed the title feat: deployment api schemas feat: deployment api surface Mar 4, 2026
@HzaRashid HzaRashid changed the title feat: deployment api surface feat: deployments api surface Mar 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

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: e784aca0-f7d9-42a0-94b8-5d4b3922720e

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 change introduces a new deployment API module with a FastAPI router and comprehensive Pydantic schemas. A new router is created at deployments.py with endpoints for provider account and deployment management, along with execution operations, currently returning HTTP 501 Not Implemented. Corresponding request/response schemas are defined in deployments.py under schemas, with validation utilities. The router is registered in the main API v1 structure.

Changes

Cohort / File(s) Summary
API Router Integration
src/backend/base/langflow/api/router.py, src/backend/base/langflow/api/v1/__init__.py
Added imports and registrations for the new deployment_router to expose it in the v1 API.
Deployments Router
src/backend/base/langflow/api/v1/deployments.py
New 276-line router module defining endpoints for provider accounts, deployments, executions, and related operations. All handlers currently return 501 Not Implemented stubs. Includes query parameter helpers like ProviderIdQuery and standardized route definitions under the /deployments prefix.
Deployments Schemas
src/backend/base/langflow/api/v1/schemas/deployments.py
New 287-line schema module with comprehensive Pydantic models for provider accounts, deployments, executions, and flow versions. Includes validation helpers (_validate_str_id_list, _normalize_optional_str) and cross-field validators (e.g., ensure_any_field_provided, validate_operations). Defines 19 schema classes covering request, response, and list item models.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 4

❌ Failed checks (1 error, 3 warnings)

Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR adds 276 lines of API router code and 287 lines of Pydantic schemas without corresponding test coverage in the established test directory. Add test file src/backend/base/langflow/tests/api/v1/test_deployments.py with unit tests for schemas, router endpoints, and serialization following project conventions.
Docstring Coverage ⚠️ Warning Docstring coverage is 52.00% 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 PR introduces 19 Pydantic schema classes and 16 endpoint handlers for deployments API with zero tests for this new API layer. Add comprehensive tests at src/backend/tests/unit/api/v1/test_deployments_schemas.py covering all 19 schemas, validation functions, and endpoint handlers with valid/invalid payloads.
Test File Naming And Structure ⚠️ Warning PR adds 563 lines of new API code (287 schemas + 276 router) without corresponding test files following established backend testing patterns. Create test files at src/backend/tests/unit/api/v1/test_deployments.py and test_deployment_schemas.py with pytest tests covering schema validation, edge cases, and review comment requirements.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: deployments api surface' accurately describes the main change - adding a new deployments API surface with routers, schemas, and endpoint definitions.
Excessive Mock Usage Warning ✅ Passed PR adds only implementation code (schemas and API endpoints) without any test files, so no mock usage to evaluate.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deployments-api-surface

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.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 23%
23.24% (8235/35429) 16.02% (4458/27826) 15.91% (1185/7445)

Unit Test Results

Tests Skipped Failures Errors Time
2631 0 💤 0 ❌ 0 🔥 42.872s ⏱️

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/backend/base/langflow/api/v1/deployments.py (1)

15-15: Prefer read-only DB dependency for GET routes.

All read handlers currently inject DbSession. Switching them to DbSessionReadOnly will reduce unnecessary write-scoped session overhead on read paths.

♻️ Proposed refactor
-from langflow.api.utils import CurrentActiveUser, DbSession
+from langflow.api.utils import CurrentActiveUser, DbSession, DbSessionReadOnly
@@
 async def list_provider_accounts(
     user: CurrentActiveUser,
-    db: DbSession,
+    db: DbSessionReadOnly,
 ):
@@
 async def get_provider_account(
     provider_id: UUID,
     user: CurrentActiveUser,
-    db: DbSession,
+    db: DbSessionReadOnly,
 ):
@@
 async def list_deployment_types(
     provider_id: ProviderIdQuery,
     user: CurrentActiveUser,
-    db: DbSession,
+    db: DbSessionReadOnly,
 ):
@@
 async def list_deployments(
     provider_id: ProviderIdQuery,
     user: CurrentActiveUser,
-    db: DbSession,
+    db: DbSessionReadOnly,
@@
 async def get_deployment_execution(
@@
-    db: DbSession,
+    db: DbSessionReadOnly,
@@
 async def get_deployment(
     deployment_id: str,
     user: CurrentActiveUser,
-    db: DbSession,
+    db: DbSessionReadOnly,
 ):
@@
 async def get_deployment_status(
     deployment_id: str,
-    db: DbSession,
+    db: DbSessionReadOnly,
     user: CurrentActiveUser,
 ):

Also applies to: 67-72, 75-85, 130-137, 140-168, 185-195, 203-210, 266-276

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/backend/base/langflow/api/v1/deployments.py` at line 15, Import and use
the read-only DB dependency instead of the write-scoped one: replace DbSession
with DbSessionReadOnly in the import line (alongside CurrentActiveUser) and
update all GET route handlers that currently depend on DbSession to depend on
DbSessionReadOnly (e.g., any function signatures using the DbSession param).
Ensure any type hints, dependency injection calls, and usages that expect a
read-only session are adjusted accordingly for functions referenced in the file
that serve GET endpoints.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/backend/base/langflow/api/v1/schemas/deployments.py`:
- Around line 241-248: DeploymentUpdateRequest currently permits no-op payloads
(e.g., {} or {"flow_versions": {}}); add a model-level validation to reject
empty updates by implementing a root_validator (prefer pre=True) on
DeploymentUpdateRequest that inspects incoming data and ensures at least one of
spec, flow_versions, or config is present and non-empty (treat empty
mappings/iterables as absent), and raise a ValueError with a clear message if
none are provided; reference the class name DeploymentUpdateRequest and its
fields spec, flow_versions, and config when locating where to add this
validator.

---

Nitpick comments:
In `@src/backend/base/langflow/api/v1/deployments.py`:
- Line 15: Import and use the read-only DB dependency instead of the
write-scoped one: replace DbSession with DbSessionReadOnly in the import line
(alongside CurrentActiveUser) and update all GET route handlers that currently
depend on DbSession to depend on DbSessionReadOnly (e.g., any function
signatures using the DbSession param). Ensure any type hints, dependency
injection calls, and usages that expect a read-only session are adjusted
accordingly for functions referenced in the file that serve GET endpoints.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61cf9d0a-eb24-484a-b52b-d199f825a708

📥 Commits

Reviewing files that changed from the base of the PR and between f0a9d98 and ebd3f7b.

📒 Files selected for processing (5)
  • src/backend/base/langflow/api/router.py
  • src/backend/base/langflow/api/v1/__init__.py
  • src/backend/base/langflow/api/v1/deployments.py
  • src/backend/base/langflow/api/v1/schemas/__init__.py
  • src/backend/base/langflow/api/v1/schemas/deployments.py

Comment on lines +241 to +248
class DeploymentUpdateRequest(BaseModel):
spec: BaseDeploymentDataUpdate | None = Field(default=None, description="Deployment metadata updates.")
flow_versions: FlowVersionsPatch | None = Field(
default=None,
description="Flow version attach/detach patch payload.",
)
config: ConfigDeploymentBindingUpdate | None = Field(default=None, description="Deployment config binding patch.")

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reject no-op deployment update payloads.

DeploymentUpdateRequest currently accepts payloads that perform no effective change (e.g. {} or {"flow_versions": {}}). This should fail validation to keep PATCH semantics explicit.

🔧 Proposed fix
 class DeploymentUpdateRequest(BaseModel):
     spec: BaseDeploymentDataUpdate | None = Field(default=None, description="Deployment metadata updates.")
     flow_versions: FlowVersionsPatch | None = Field(
         default=None,
         description="Flow version attach/detach patch payload.",
     )
     config: ConfigDeploymentBindingUpdate | None = Field(default=None, description="Deployment config binding patch.")
+
+    `@model_validator`(mode="after")
+    def ensure_any_field_provided(self) -> DeploymentUpdateRequest:
+        has_flow_version_changes = bool(
+            self.flow_versions and (self.flow_versions.add or self.flow_versions.remove)
+        )
+        if self.spec is None and self.config is None and not has_flow_version_changes:
+            msg = "At least one update field must be provided."
+            raise ValueError(msg)
+        return self
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/backend/base/langflow/api/v1/schemas/deployments.py` around lines 241 -
248, DeploymentUpdateRequest currently permits no-op payloads (e.g., {} or
{"flow_versions": {}}); add a model-level validation to reject empty updates by
implementing a root_validator (prefer pre=True) on DeploymentUpdateRequest that
inspects incoming data and ensures at least one of spec, flow_versions, or
config is present and non-empty (treat empty mappings/iterables as absent), and
raise a ValueError with a clear message if none are provided; reference the
class name DeploymentUpdateRequest and its fields spec, flow_versions, and
config when locating where to add this validator.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 69.42446% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.36%. Comparing base (335656f) to head (7a4352f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ackend/base/langflow/api/v1/schemas/deployments.py 68.98% 67 Missing ⚠️
src/backend/base/langflow/api/v1/deployments.py 70.49% 18 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12041      +/-   ##
==========================================
- Coverage   37.45%   37.36%   -0.10%     
==========================================
  Files        1616     1617       +1     
  Lines       79060    79067       +7     
  Branches    11946    11946              
==========================================
- Hits        29614    29540      -74     
- Misses      47788    47870      +82     
+ Partials     1658     1657       -1     
Flag Coverage Δ
backend 57.06% <69.42%> (-0.37%) ⬇️
frontend 20.82% <ø> (ø)
lfx 42.37% <ø> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
src/backend/base/langflow/api/router.py 100.00% <100.00%> (ø)
src/backend/base/langflow/api/v1/deployments.py 70.49% <70.49%> (ø)
...ackend/base/langflow/api/v1/schemas/deployments.py 68.98% <68.98%> (ø)

... and 12 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.

@HzaRashid HzaRashid force-pushed the deployments-api-surface branch from ebd3f7b to 962f04f Compare March 4, 2026 19:58
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@HzaRashid HzaRashid marked this pull request as draft March 4, 2026 21:04
- Strip internal implementation details from public-facing Field
  descriptions and endpoint docstrings (adapter routing, provider
  snapshots, binding payloads, lazy sync)
- Rename flow_versions to flow_version_ids in DeploymentCreateRequest
  and DeploymentUpdateRequest for clarity
- Remove redundant match_limit query parameter from list_deployments;
  page size already caps results
The API schema file inherited from and directly embedded service-layer
types whose identifier fields use IdLike (UUID | str) for provider-owned
IDs. This conflated provider-owned opaque identifiers with Langflow
DB-managed UUIDs at the API boundary.

- Rewrite RedeployResponse as standalone BaseModel instead of inheriting
  from DeploymentOperationResult (which carried id: IdLike)

- Replace ConfigItem with API-local DeploymentConfigCreate
  (reference_id: str, explicitly provider-owned)

- Replace ConfigDeploymentBindingUpdate with API-local
  DeploymentConfigBindingUpdate (config_id: str, not IdLike union)

- Add module docstring documenting the two identifier domains
  (Langflow DB UUIDs vs provider-owned opaque strings)

- Annotate all id/provider_* fields with their ownership domain

- Keep BaseDeploymentData/BaseDeploymentDataUpdate imports
  (no ID fields, stable shapes)
@HzaRashid HzaRashid force-pushed the deployments-api-surface branch from d5b948e to bff15e2 Compare March 4, 2026 22:01
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 4, 2026
@github-actions github-actions bot removed the enhancement New feature or request label Mar 4, 2026
@github-actions github-actions bot added the enhancement New feature or request label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant