Fix Network.post() silently dropping falsy-but-defined params from FormData#909
Merged
Fix Network.post() silently dropping falsy-but-defined params from FormData#909
Conversation
…rmData The falsy check `if (!value)` drops false, 0, '', null, and undefined — causing csrfToken (and potentially other valid params) to be silently omitted from multipart FormData requests when the value is undefined or another falsy type. The keepalive() method in the same file already uses the correct check `if (value === undefined)`. Aligning post() to the same guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
Valforte
approved these changes
Apr 13, 2026
Contributor
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.
Fix Network.post() silently dropping falsy-but-defined values from FormData.
The check
if (!value)is a falsy guard — it drops false, 0, '', null, and undefined. For multipart requests (those containing a File or Blob), this meant parameters likecsrfTokencould be silently omitted from the FormData body if their value was falsy.The
keepalive()method in the same file already uses the correct guardif (value === undefined). This alignspost()to match.History: This fix was originally made in 2020 (commit 832cd5a) and then reverted 10 minutes later in the same PR (#262) as "an unnecessary change" with no further explanation. The revert left
keepalive()with the correctundefinedcheck whilepost()regressed back to the falsy check.Behavioral change for callers: Boolean
false,null,0, and''values were previously dropped from FormData silently. After this fix they are included and serialized by FormData (false → 'false', null → 'null', etc.). Audited Web-Expensify callers of file upload commands — the affected falsy values are booleanfalse(e.g.shouldSkipSmartScan,isManualRequestScan) andundefined. PHP'sStr::toBool()(used byRequest::getBool) callsfilter_var($input, FILTER_VALIDATE_BOOLEAN)which correctly maps the string"false"→false, so behavior is unchanged.Fixed Issues
$ https://github.com/Expensify/Expensify/issues/535855
Tests
post()only uses FormData assettings.datawhen aFileorBlobis present in parameters (i.e., receipt/attachment upload commands). Regular API calls are unaffected — they usesettings.data = parameters(the plain object).QA
Regression — receipt upload still works end-to-end:
Expense_CreateExpense_CreatePOST requestcsrfTokenis present with a non-empty valueisManualRequestScanis present with value"false"(previously this was dropped; now it is sent as the string"false", which PHP correctly interprets asfalse)Regression — non-file API calls unaffected:
application/x-www-form-urlencodedor JSON)