-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
fix(client-fetch): ensures plain/text body is sent with request #2564
Conversation
|
|
🦋 Changeset detectedLatest commit: f653716 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
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. |
mrlubos
left a comment
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2564 +/- ##
==========================================
+ Coverage 23.59% 24.05% +0.46%
==========================================
Files 363 363
Lines 36545 36585 +40
Branches 1562 1628 +66
==========================================
+ Hits 8622 8802 +180
+ Misses 27910 27770 -140
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 |
…nt with request refs: hey-api#2553
|
Changing how the angular client works would be a breaking change, and I don't think that should be done as part of this PR. |
Sounds good! What would be the breaking change? |
packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts
Outdated
Show resolved
Hide resolved
serializedBody will go from being initialized with options.body to being undefined, so in the case of unserialized data - it would break that functionality for anyone leveraging that value in the interceptor. |
I think that's fine, what do you think? Isn't that how it works for the Fetch client too? |
The fetch client does work like that. I felt that a breaking change warranted it is own issue with a description of what changed and why. However, if this is not a concern, I will push the change. |
…s sent with request BREAKING CHANGE: options.serializedBody is undefined by default, and will only be assigned a value when options.bodySerializer is defined refs: hey-api#2553
|
Yeah I'm not overly concerned with it as both the Angular client and serialized body are relatively new changes. We can document it in release notes, the pull request looks ready now I think. I'll review it one last time and merge later, thank you for the big contribution! |
Thank you! |
mrlubos
left a comment
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.
This looks good! I think we need to improve the Axios client as well, but happy to merge it
|
Ok, I can help with that. I'll create an issue and start looking into it later on this evening. |
resolves: #2553
When the
options.serializedBodyproperty was introduced, it replaced the body sent in the Request object causing anyoptions.bodynot requiring abodySerializer(ie plain/text) to be omitted from the request.This PR fixes this behavior, ensuring that when an
options.bodyis defined it is sent with the Request 'as-is', or 'serialized' if anoptions.bodySerializeris defined.