Skip to content

fix: handle form-urlencoded content type with charset#8397

Open
redpandaex wants to merge 1 commit into
usebruno:mainfrom
redpandaex:bugfix/form-urlencoded-content-type-charset
Open

fix: handle form-urlencoded content type with charset#8397
redpandaex wants to merge 1 commit into
usebruno:mainfrom
redpandaex:bugfix/form-urlencoded-content-type-charset

Conversation

@redpandaex

@redpandaex redpandaex commented Jun 27, 2026

Copy link
Copy Markdown

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Fixes #8377

This normalizes the Content-Type media type before detecting form-urlencoded requests, so values like application/x-www-form-urlencoded;charset=UTF-8 still use the form-url-encoded serialization and interpolation path.

VSCode extension does not reproduce the issue because parts of its request path also use the body mode as a fallback. This PR keeps the Desktop/CLI fix focused on recognizing valid Content-Type media type parameters.

Tests:

  • npm run build:bruno-common
  • npm run test --workspace=packages/bruno-common -- src/utils/form-data.spec.ts
  • node --experimental-vm-modules ../../node_modules/jest/bin/jest.js tests/network/interpolate-vars.spec.js
  • node --experimental-vm-modules ../../node_modules/jest/bin/jest.js tests/runner/interpolate-vars.spec.js
  • git --no-pager diff --check
  • Desktop manual test with Content-Type: application/x-www-form-urlencoded;charset=UTF-8, verified request body is termId=123&question=hello

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of application/x-www-form-urlencoded requests, including values with additional parameters like charset.
    • Form fields in request bodies are now interpolated correctly even when the content type is not an exact match.
  • Tests

    • Added coverage for URL-encoded form requests with parameterized content types.
    • Expanded utility tests to verify broader content-type matching and non-string inputs.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b20818e-4aa2-466b-9c23-0dccc159114a

📥 Commits

Reviewing files that changed from the base of the PR and between 87f7426 and 7dc7fba.

📒 Files selected for processing (9)
  • packages/bruno-cli/src/runner/interpolate-vars.js
  • packages/bruno-cli/src/runner/run-single-request.js
  • packages/bruno-cli/tests/runner/interpolate-vars.spec.js
  • packages/bruno-common/src/utils/form-data.spec.ts
  • packages/bruno-common/src/utils/form-data.ts
  • packages/bruno-common/src/utils/index.ts
  • packages/bruno-electron/src/ipc/network/index.js
  • packages/bruno-electron/src/ipc/network/interpolate-vars.js
  • packages/bruno-electron/tests/network/interpolate-vars.spec.js

Walkthrough

The PR adds a shared isFormUrlEncodedContentType helper, reuses it in CLI and Electron request-body interpolation/serialization paths, and extends tests to cover application/x-www-form-urlencoded values with parameters such as charset=UTF-8.

Changes

Form URL Encoded detection

Layer / File(s) Summary
Shared form-urlencoded predicate and tests
packages/bruno-common/src/utils/form-data.ts, packages/bruno-common/src/utils/index.ts, packages/bruno-common/src/utils/form-data.spec.ts
Adds isFormUrlEncodedContentType, re-exports it, and adds coverage for exact, parameterized, mixed-case, and non-string inputs.
CLI request-body handling
packages/bruno-cli/src/runner/interpolate-vars.js, packages/bruno-cli/src/runner/run-single-request.js, packages/bruno-cli/tests/runner/interpolate-vars.spec.js
Uses the shared predicate in CLI form-url-encoded interpolation and serialization, with a test for charset-qualified request bodies.
Electron request-body handling
packages/bruno-electron/src/ipc/network/index.js, packages/bruno-electron/src/ipc/network/interpolate-vars.js, packages/bruno-electron/tests/network/interpolate-vars.spec.js
Uses the shared predicate in Electron form-url-encoded interpolation and pre-request serialization, with a test for charset-qualified request bodies.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

A helper hummed through Content-Type space,
Ignoring ;charset with quiet grace.
CLI and Electron now read form fields the same,
So termId and question keep their names.
🪄 Forms fly straight; the rows stay sane.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main fix: handling charset parameters on form-urlencoded content types.
Linked Issues check ✅ Passed The changes normalize form-urlencoded detection and add tests, matching issue #8377's requirement to handle charset parameters correctly.
Out of Scope Changes check ✅ Passed The PR stays scoped to form-urlencoded content-type handling and related tests, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@redpandaex

Copy link
Copy Markdown
Author

Linked to #8377.

I verified the fix locally with:

  • npm run build:bruno-common
  • npm run test --workspace=packages/bruno-common -- src/utils/form-data.spec.ts
  • node --experimental-vm-modules ../../node_modules/jest/bin/jest.js tests/network/interpolate-vars.spec.js
  • node --experimental-vm-modules ../../node_modules/jest/bin/jest.js tests/runner/interpolate-vars.spec.js
  • git --no-pager diff --check

I also manually tested Bruno Desktop with Content-Type: application/x-www-form-urlencoded;charset=UTF-8 and confirmed the request body is sent as termId=123&question=hello.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Form URL Encoded body is serialized as 0[name]/0[value] when Content-Type is application/x-www-form-urlencoded;charset=UTF-8

1 participant