fix(runtime): forward a bare body on PATCH/PUT like POST#3
Merged
Conversation
A no-path endpoint's generated wrapper passes the request body directly (no `body` key). handlePatchCommand/handlePutCommand only forwarded input.body, so the bare body was silently dropped and an empty PATCH/PUT was sent. Match handlePostCommand's fallback (body: hasBody ? input.body : input). Adds regression tests. Bumps to 0.1.7.
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.
Problem
A no-path endpoint's generated command wrapper passes the request body directly (there is no
path/bodykey), e.g.patchUsersCommand({ firstName, lastName }). ButhandlePatchCommand/handlePutCommandonly forwardedinput.body:Since a bare body has no
bodykey,hasBodyisfalseand the body was silently dropped — an empty PATCH/PUT was sent.handlePostCommandalready handled this correctly via a fallback (body: hasBody ? input.body : input), which is why POST worked but PATCH/PUT didn't on the same no-path shape.Real-world impact: a profile-update form calling
patchUsersCommand({ firstName, lastName })sent an empty request; the fields never reached the server.Fix
Make
handlePatchCommandandhandlePutCommanduse the same bare-body fallback ashandlePostCommand:{ path, body }and{ body }shapes are unchanged (hasBodytrue →input.body).{ ...fields }) is now forwarded as the request body.Tests
Added regression tests for both
handlePatchCommandandhandlePutCommandcovering the bare-body (no path/body key) shape. Full suite: 93 passing.Bumps version to 0.1.7 so the publish workflow ships it.