fix(network): handle_route reads top-level body field as RouteRespons…#1354
Open
uraraneko wants to merge 1 commit into
Open
fix(network): handle_route reads top-level body field as RouteRespons…#1354uraraneko wants to merge 1 commit into
uraraneko wants to merge 1 commit into
Conversation
…e fallback When --body is passed via CLI, it is stored as a top-level "body" field in the command JSON, but handle_route only reads from the nested "response" object. This adds an or_else fallback that constructs a RouteResponse (status 200, content-type application/json) from the top-level "body" field when "response" is absent. Refs vercel-labs#1353
Contributor
|
@uraraneko is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix:
network route --bodynot working — handler reads top-levelbodyas fallbackCloses #1353
Problem
The
--bodyflag onnetwork routehas no effect. Intercepted requests are passed through to the real backend instead of being stubbed withthe provided response body.
Root Cause
The CLI parser (
cli/src/commands.rs:2516) stores the--bodyvalue as a top-level"body"field in the command JSON:{ "id": "...", "action": "route", "url": "**/api/users", "abort": false, "body": "{\"users\":[]}" }However, handle_route (cli/src/native/actions.rs:7096-7109) only reads from the nested "response" object to construct a RouteResponse. The
top-level "body" field is never accessed, so RouteEntry.response ends up as None, and resolve_fetch_paused skips Fetch.fulfillRequest —
falling through to Fetch.continueRequest, which lets the request reach the real backend.
Fix
Added an or_else fallback in handle_route that reads the top-level "body" field when "response" is not present, constructing a RouteResponse
with sensible defaults (status 200, content-type application/json):
This approach:
Verification