Skip to content

fix: Fixes broken multipart/form-data construction#38644

Open
KumarHarshit3603 wants to merge 2 commits into
RocketChat:developfrom
KumarHarshit3603:formdata-fix
Open

fix: Fixes broken multipart/form-data construction#38644
KumarHarshit3603 wants to merge 2 commits into
RocketChat:developfrom
KumarHarshit3603:formdata-fix

Conversation

@KumarHarshit3603
Copy link
Copy Markdown

@KumarHarshit3603 KumarHarshit3603 commented Feb 12, 2026

Proposed changes

  • Fix buildFormData so it walks nested data correctly: call order is now data[key], formData.
  • Only skip appending when the value is actually null/undefined, so files and fields don’t get dropped.
  • Uploads and other multipart requests now send the full payload instead of an empty body.

Issue(s)

  • Multipart/form-data was empty when payloads contained a File (no public issue linked).

Steps to test or reproduce

  1. Use payload { meta: { tag: 'note' }, file: new File(['hi'], 'greet.txt') }.
  2. On develop, RestClient.post('/v1/upload', payload) sends an empty body.
  3. On this branch, the same call includes meta[tag] and file in FormData.
  4. Automated: cd packages/api-client && yarn test (add a small spec to assert FormData entries).

Further comments

  • Behavior-only bug fix in packages/api-client/src/index.ts; no public API changes.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 12, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 12, 2026

⚠️ No Changeset found

Latest commit: fd280f0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 12, 2026

Walkthrough

A recursive parameter order was corrected in the buildFormData function. The function now passes data and formData in the proper sequence during nested object traversal, ensuring correct handling of form data accumulation across recursive calls.

Changes

Cohort / File(s) Summary
Recursive Parameter Fix
packages/api-client/src/index.ts
Swapped argument order in buildFormData recursive call from buildFormData(formData, data[key], parentKey) to buildFormData(data[key], formData, parentKey) to correctly map data source and accumulator parameters during nested object traversal.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

Hoppity-hop through nested trees,
Parameters swapped with ease,
Data flows in proper order now,
Forms accumulate, and how!
🐰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Fixes broken multipart/form-data construction' directly and clearly describes the main change—fixing a bug in the buildFormData function that was preventing proper multipart/form-data construction.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 1 file

@KumarHarshit3603
Copy link
Copy Markdown
Author

Hey! @ggazzo can you please review 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.

1 participant