Repository navigation
fix: prevent React state mutation by spreading envelope.recipients before sort - #2839
Conversation
…fore sort Bug #1 from Faultmark scan (issue documenso#2829): nextRecipient useMemo sorted envelope.recipients in-place, permanently mutating the React state object. After the first render, all downstream logic including selectedAssistantRecipient and assistantRecipients produced incorrect results. Fix: Spread envelope.recipients into a new array before sorting. Signed-off-by: Abdulazez A. <[email protected]>
|
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 |
|
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 |
Summary
Fixes bug #1 from the Faultmark scan (issue #2829):
envelope.recipients.sort()was called directly on the React state object inside auseMemo, permanently mutating it in-place.Root cause
const sortedRecipients = envelope.recipients.sort((a, b) => ...)on line 297 sorted the array in-place, corrupting the React state. After the first render with sequential signing enabled,selectedAssistantRecipientandassistantRecipientswould produce incorrect results.Fix
Changed to
[...envelope.recipients].sort(...)— creating a shallow copy before sorting, leaving the original state array unmodified.Verification
npx tsc --noEmitPartially addresses #2829