Skip to content

fix(workflows): preserve pipelines key when proxying resolve to cloud#1020

Merged
leszko merged 1 commit intomainfrom
rafal/fix-featured-workflows
Apr 30, 2026
Merged

fix(workflows): preserve pipelines key when proxying resolve to cloud#1020
leszko merged 1 commit intomainfrom
rafal/fix-featured-workflows

Conversation

@leszko
Copy link
Copy Markdown
Collaborator

@leszko leszko commented Apr 30, 2026

Summary

Selecting any featured workflow while connected to cloud failed with Cloud proxy request failed: status: 422 ... loc: ['body', 'pipelines'], msg: 'Field required' — affecting every workflow, including the bundled starters.

Root cause

_merge_legacy_pipelines was popping pipelines out of the request dict during Pydantic validation:

legacy = data.pop("pipelines", None)   # mutates the cached body
data["nodes"] = combined

Starlette caches the parsed request JSON on request._json and returns the same dict reference on every await request.json() call. FastAPI handed that cached dict to Pydantic for validation, then cloud_proxy._proxy_to_cloud read it again to forward the body upstream — by which point pipelines had been stripped and only nodes remained. Older cloud builds still require pipelines and rejected the resulting nodes-only payload, so every proxied workflow blew up.

Reproduced before the fix:

BEFORE validation: ['format', 'pipelines']
AFTER validation:  ['format', 'nodes']

Fix

Return a new dict from the validator instead of mutating the input. The original request._json is left alone, so whatever the frontend sent (legacy pipelines, new nodes, or both) reaches the cloud verbatim. Internal model semantics are unchanged: wf.nodes still combines both keys for in-process consumers.

Compatibility matrix after this fix

Client Behavior
New Electron (post-fix) Body forwarded as-is — works with any cloud
Recent preview Electron (post-#980, pre-fix) Local validator still mutates locally, but new cloud accepts nodes
Pre-#980 stable (v0.2.3) Works when frontend sends pipelines; out of our reach for nodes-only

Test plan

  • uv run pytest tests/test_workflow_resolve.py — 54 passed (includes new test_validation_does_not_mutate_input_dict regression).
  • uv run ruff check src/scope/core/workflows/resolve.py tests/test_workflow_resolve.py — clean.
  • uv run ruff format --check — clean.
  • Manually verify: select a featured workflow in the Electron preview while connected to cloud — no longer 422s.

🤖 Generated with Claude Code

Starlette caches the parsed request JSON on ``request._json`` and
returns the same dict reference on every ``request.json()`` call.
``_merge_legacy_pipelines`` was popping ``pipelines`` out of that cached
dict during Pydantic validation, so when ``cloud_proxy`` later read the
body to forward it upstream, ``pipelines`` was already gone. Old cloud
builds still require ``pipelines`` and rejected the resulting
``nodes``-only body with ``body.pipelines: Field required`` — affecting
every workflow proxied to cloud, including bundled starter workflows.

Return a new dict from the validator instead. The original body is
preserved verbatim, so whatever the frontend sent (legacy ``pipelines``,
new ``nodes``, or both) is what reaches the cloud.

Adds a regression test asserting model_validate does not mutate its
input.

Signed-off-by: Rafał Leszko <rafal@livepeer.org>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Important

Review skipped

Auto 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bdb0c02a-fcda-402f-b73b-0674c38eca75

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rafal/fix-featured-workflows

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.

@leszko leszko merged commit ba357fb into main Apr 30, 2026
2 of 8 checks passed
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.

1 participant