-
-
Notifications
You must be signed in to change notification settings - Fork 233
fix(client-fetch): ensures plain/text body is sent with request #2564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(client-fetch): ensures plain/text body is sent with request #2564
Conversation
|
|
Someone is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
@mrlubos assistance is requested to address next steps in resolving pipeline errors. |
@@ -78,9 +78,12 @@ export const createClient = (config: Config = {}): Client => { | |||
const requestInit: ReqInit = { | |||
redirect: 'follow', | |||
...opts, | |||
body: opts.serializedBody, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't all that you want something like this?
body: opts.serializedBody !== undefined ? opts.serializedBody : opts.body,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought about going the opts.serializedBody ?? opts.body
route but decided to put it in a separate block for readability and clarity.
Body is already a property on the options object, no need to define or reassign if its not necessary. It was confusing for me to see body redefined in the client-next plugin like body: options.body
. I had to ask myself if something was different - it wasn't.
Happy to change it if you prefer the one liner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the logic in all clients using serializedBody
and then update snapshots with pnpm --filter @test/openapi-ts test:update
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2564 +/- ##
==========================================
+ Coverage 23.69% 23.98% +0.28%
==========================================
Files 362 362
Lines 36340 36345 +5
Branches 1562 1603 +41
==========================================
+ Hits 8612 8716 +104
+ Misses 27715 27616 -99
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@mrlubos the next client was the only client impacted by the serializeBody change - that has issue has now been resolved as part of this PR. Tests have been added, snapshots updated. |
Isn't this line going to have the same issue? openapi-ts/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts Line 98 in 34fa59f
|
@mrlubos I reviewed the changes tracked in the issue that triggered the bug which were the client-fetch and client-next clients. I did not go through and review all of the clients. However, I can do that, starting with your reference to the angular client. |
Yes please. Aside from making sure this bug isn't present in any of the clients, I think there are 2 issues with this change.
|
@mrlubos the angular client would not have this issue because openapi-ts/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts Line 70 in 34fa59f
|
@mrlubos - looking at the angular client, would be acceptable to initialize the |
That's either a mistake we want to fix or a valid approach we should use across all clients. I don't know what's the better approach, and I don't feel particularly strongly about either option. The only thing I feel strongly about is having it be consistent so one can easily reason through these features |
Agreed. I'm writing tests for the different scenarios. Will post back when I have it sorted out. |
…ent with request refs: hey-api#2553
@mrlubos I pushed just the fetch client changes. If these changes make sense, I will update the other clients. |
@mrlubos A body defined as 0 or false with defined bodySerializer will not make it into the expected block openapi-ts/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts Line 61 in 34fa59f
Should this check be updated as part of this PR? |
Yes please |
I agree |
resolves: #2553
When the
options.serializedBody
property was introduced, it replaced the body sent in the Request object causing anyoptions.body
not requiring abodySerializer
(ie plain/text) to be omitted from the request.This PR fixes this behavior, ensuring that when an
options.body
is defined it is sent with the Request 'as-is', or 'serialized' if anoptions.bodySerializer
is defined.