Skip to content
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

1.7.8 introduce breaking behavior in payload json serialization #123

Closed
c-eliasson opened this issue Feb 1, 2022 · 4 comments
Closed

1.7.8 introduce breaking behavior in payload json serialization #123

c-eliasson opened this issue Feb 1, 2022 · 4 comments
Labels

Comments

@c-eliasson
Copy link

With the release of 1.7.8, a breaking change was introduced in how payload serialization works when no explicit content-type has been set.

Under HTTP methods the documentation states:

NOTE: For methods having a body argument if the value is an Object it is assumed that it is a JSON payload and apply the same behaviour as calling .json(body), unless the Content-Type header has been set to something else beforehand.

We've relied on this and simply call .post({ foo: 'bar' }) to send a json serialized payload, without explicitly specifying the content-type. This has worked fine up until 1.7.7, but broke with the 1.7.8 release.

After digging through the changes in 1.7.8, I believe I've found the problematic commit. The problem seems to be this line. If I'm not missing something, it relies on no headers at all being set in order for the automatic json serialization to work. In our case we set the authorization header on all requests, which in our case means base._options.headers is defined, even though we haven't set any other headers.

I haven't had time to create a repro or look into a fix unfortunately, but after looking at the code I believe this is the issue.

Workaround

For anyone running into this issue, switching to 1.7.7 solve the problem.

@elbywan
Copy link
Owner

elbywan commented Feb 1, 2022

@c-eliasson Sorry for this, I'll investigate asap.

@elbywan elbywan added the bug label Feb 1, 2022
elbywan added a commit that referenced this issue Feb 1, 2022
@elbywan
Copy link
Owner

elbywan commented Feb 1, 2022

@c-eliasson

Allright so I just released v1.7.9 including a fix which, I hope, will solve the problem.

Sorry again for the regression 🙇.

@c-eliasson
Copy link
Author

@elbywan Wow, thanks for the swift reply! I'll take it for a spinn as soon as I get a chance. Will get back to you shortly.

@c-eliasson
Copy link
Author

@elbywan Can confirm that bumping to 1.7.9 resolved the issue, and the automatic payload serialization now appear to work as expected for us again.

Thanks for the quick fix, and the great work you're doing with wretch! 👏

elbywan added a commit that referenced this issue Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants