Skip to content

[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
OpenAPITools:masterfrom
MarcelKonrad:issue-23998
Open

[BUG][TYPESCRIPT-FETCH] Fix #23998: Form data requests with mime type parameters use URLSearchParams instead of FormData#24000
MarcelKonrad wants to merge 2 commits into
OpenAPITools:masterfrom
MarcelKonrad:issue-23998

Conversation

@MarcelKonrad

@MarcelKonrad MarcelKonrad commented Jun 11, 2026

Copy link
Copy Markdown

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

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-fetch when MIME parameters are present, so requests now use FormData instead of URLSearchParams. Fixes #23998.

  • Bug Fixes
    • In canConsumeForm, replace strict equality with startsWith('multipart/form-data') to handle content types like multipart/form-data; charset=UTF-8.

Written for commit 9a9ca47. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@macjohnny macjohnny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

@macjohnny

Copy link
Copy Markdown
Member

@MarcelKonrad please update the samples

@MarcelKonrad

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][TYPESCRIPT-FETCH] Form data requests with mime type parameters use URLSearchParams instead of FormData

2 participants