Repository navigation
fix: prevent prop array mutation by spreading allRecipients before sort - #2840
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@Abzaek is attempting to deploy a commit to the Documenso Team Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey there, it looks like you haven't accepted our contributor license agreement yet. In order for us to accept your pull request we ask that you please fill out the CLA: https://documen.so/cla |
Bug #2 from Faultmark scan (issue documenso#2829): nextRecipient useMemo sorted allRecipients in-place, permanently reordering the parent's prop array. This broke selectedSigner lookup and field filtering that depended on original recipient order. Fix: Spread allRecipients into a new array before sorting. Signed-off-by: Abdulazez A. <[email protected]>
76921e8 to
a50a07b
Compare
Summary
Fixes bug #2 from the Faultmark scan (issue #2829):
allRecipients.sort()was called directly on the prop array inside auseMemo, permanently reordering the parent's array.Root cause
const sortedRecipients = allRecipients.sort((a, b) => ...)on line 145 sorted the array in-place. After the first render,selectedSigner = allRecipients?.find(r => r.id === selectedSignerId)and field filtering that depended on original recipient order would break.Fix
Changed to
[...allRecipients].sort(...)— creating a shallow copy before sorting, leaving the original prop array unmodified.Partially addresses #2829