Fetch gateway does not normalize HTTP method casing, leading to request issues with undici #584
Open
juniorvanin wants to merge 2 commits intotulios:masterfrom
Open
Fetch gateway does not normalize HTTP method casing, leading to request issues with undici #584juniorvanin wants to merge 2 commits intotulios:masterfrom
juniorvanin wants to merge 2 commits intotulios:masterfrom
Conversation
🦋 Changeset detectedLatest commit: 74bc955 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Collaborator
klippx
requested changes
Apr 24, 2025
Collaborator
klippx
left a comment
There was a problem hiding this comment.
Hello, thanks for the contribution! I think it makes sense, but you need to fix tests too, please 🙏
|
|
||
| const headers = assign(customHeaders, this.request.headers()) | ||
| const method = this.shouldEmulateHTTP() ? 'post' : requestMethod | ||
| const method = this.shouldEmulateHTTP() ? 'POST' : requestMethod.toUpperCase() |
Collaborator
There was a problem hiding this comment.
The same should be done in two more files, I know this was originally only for Fetch gateway but the way I see it this is not about your specific case and changing Fetch to be different just because of undici:
src/gateway/http.tssrc/gateway/xhr.ts
| 'mappersmith': patch | ||
| --- | ||
|
|
||
| Update the performRequest method in the Fetch gateway to normalize the HTTP method to uppercase to mitigate issue with PATCH calls and undici |
Collaborator
There was a problem hiding this comment.
Suggested change
| Update the performRequest method in the Fetch gateway to normalize the HTTP method to uppercase to mitigate issue with PATCH calls and undici | |
| Update the `performRequest` method in all gateways to normalize the HTTP method to uppercase. This is to ensure users of mappersmith can continue to use lowercase methods in their manifest and still be compatible with fetch libraries that are equipped with a case sensitive fetch mechanism. |
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.
It appears that the Fetch gateway in Mappersmith does not normalize the HTTP method to uppercase, which can cause issues when using HTTP clients like undici that are case-sensitive about method names.
This is a small fix for an issue related to PATCH requests not working properly producing a 400 Bad Request error.