-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Sanitize waypoint fields before sending to API #69549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
87e07f1
Sanitize waypoint fields before sending to API
neil-marcellini 4cb9be4
Fix: Preserve keyForList in Onyx optimistic data
neil-marcellini 5441e05
Fix ESLint errors in unit tests
neil-marcellini b8646eb
Merge main into neil-fix-distance
neil-marcellini 0644dc1
Replace sanitizeRecentWaypoints with sanitizeWaypointsForAPI
neil-marcellini 04141b6
Address AI review feedback on waypoint sanitization
neil-marcellini 588d3a1
Use stringifyWaypointsForAPI consistently across all call sites
MelvinBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are introduces
stringifyWaypointsForAPIspecifically to encapsulateJSON.stringify(sanitizeWaypointsForAPI(...)), and uses it in 2 places (getUpdateMoneyRequestParamsandgetUpdateTrackExpenseParams). However, 3 other call sites still use the manualJSON.stringify(sanitizeWaypointsForAPI(...))pattern:[IOU/index.ts:6416] — convertBulkTrackedExpensesToIOU
[IOU/index.ts:6700]— requestMoney
[IOU/index.ts:7499] — trackExpense
These should use
stringifyWaypointsForAPI(...)for consistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MelvinBot please address this and update the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into this and confirmed there are 4 call sites still using the manual
JSON.stringify(sanitizeWaypointsForAPI(...))pattern instead ofstringifyWaypointsForAPI(...):src/libs/actions/Transaction.ts:399—getRoutesrc/libs/actions/IOU/index.ts:6416—convertBulkTrackedExpensesToIOUsrc/libs/actions/IOU/index.ts:6700—requestMoneysrc/libs/actions/IOU/index.ts:7499—trackExpenseThe fix for each:
Transaction.ts:399 — direct replacement:
IOU/index.ts:6416, 6700, 7499 — keep the null guard, replace the stringify call:
(Same pattern for the other two sites.)
Also, once the
sanitizeWaypointsForAPIimport is no longer directly used inIOU/index.ts, it should be removed from the import statement at line 243.This comment was marked as duplicate.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MelvinBot Okay, now you are an assignee. Please go ahead and implement this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Pushed 588d3a1 which replaces all 4 remaining manual
JSON.stringify(sanitizeWaypointsForAPI(...))calls withstringifyWaypointsForAPI(...):src/libs/actions/Transaction.ts:399—getRoutesrc/libs/actions/IOU/index.ts:6416—convertBulkTrackedExpensesToIOUsrc/libs/actions/IOU/index.ts:6700—requestMoneysrc/libs/actions/IOU/index.ts:7499—trackExpenseNote:
sanitizeWaypointsForAPIis still imported inIOU/index.tsbecause it's used directly (withoutJSON.stringify) at line 8443.