[BUG][TYPESCRIPT-FETCH] Fix #23998: Form data requests with mime type parameters use URLSearchParams instead of FormData#24000
Open
MarcelKonrad wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 20 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts">
<violation number="1" location="samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts:372">
P2: MIME type detection in `canConsumeForm` is case-sensitive, which violates RFC 2045/7231 case-insensitivity rules for media types. Mixed-case `multipart/form-data` values (e.g., `Multipart/Form-Data`) will incorrectly bypass FormData selection.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| export function canConsumeForm(consumes: Consume[]): boolean { | ||
| for (const consume of consumes) { | ||
| if ('multipart/form-data' === consume.contentType) { | ||
| if (consume.contentType?.startsWith('multipart/form-data') == true) { |
Contributor
There was a problem hiding this comment.
P2: MIME type detection in canConsumeForm is case-sensitive, which violates RFC 2045/7231 case-insensitivity rules for media types. Mixed-case multipart/form-data values (e.g., Multipart/Form-Data) will incorrectly bypass FormData selection.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts, line 372:
<comment>MIME type detection in `canConsumeForm` is case-sensitive, which violates RFC 2045/7231 case-insensitivity rules for media types. Mixed-case `multipart/form-data` values (e.g., `Multipart/Form-Data`) will incorrectly bypass FormData selection.</comment>
<file context>
@@ -369,7 +369,7 @@ export function mapValues(data: any, fn: (item: any) => any) {
export function canConsumeForm(consumes: Consume[]): boolean {
for (const consume of consumes) {
- if ('multipart/form-data' === consume.contentType) {
+ if (consume.contentType?.startsWith('multipart/form-data') == true) {
return true;
}
</file context>
Member
|
@MarcelKonrad please update the samples |
Author
|
Thanks, @macjohnny, for the review. I re-ran the scripts of the PR template, but there were no changed files. The CI error indicates an issue with the TypeScript version, which is unrelated to this PR. |
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.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Fixes #23998. A description and a guide on how to reproduce the issue can be found there.
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @dennisameling
Summary by cubic
Fixes incorrect detection of multipart form data in
typescript-fetchwhen MIME parameters are present, so requests now use FormData instead of URLSearchParams. Fixes #23998.canConsumeForm, replace strict equality withstartsWith('multipart/form-data')to handle content types likemultipart/form-data; charset=UTF-8.Written for commit 9a9ca47. Summary will update on new commits.