Skip to content

fix: prevent prop array mutation by spreading allRecipients before sort - #2840

Merged
dguyen merged 3 commits into
documenso:mainfrom
Abzaek:fix/allrecipients-sort-mutation
May 26, 2026
Merged

dguyen merged 3 commits into
documenso:mainfrom
Abzaek:fix/allrecipients-sort-mutation

Conversation

@Abzaek

@Abzaek Abzaek commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes bug #2 from the Faultmark scan (issue #2829): allRecipients.sort() was called directly on the prop array inside a useMemo, 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

@vercel

vercel Bot commented May 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
prd-docs Ignored Ignored May 26, 2026 4:09am
prd-openpage-api Ignored Ignored May 26, 2026 4:09am
stg-docs Skipped Skipped May 26, 2026 4:09am

Request Review

@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3de069f5-7191-498d-be77-290dc59a2536

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown

@Abzaek is attempting to deploy a commit to the Documenso Team Team on Vercel.

A member of the Team first needs to authorize it.

@Mythie

Mythie commented May 20, 2026

Copy link
Copy Markdown
Collaborator

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]>
@Abzaek
Abzaek force-pushed the fix/allrecipients-sort-mutation branch from 76921e8 to a50a07b Compare May 22, 2026 11:07
@vercel
vercel Bot temporarily deployed to Preview – stg-docs May 26, 2026 04:09 Inactive

@dguyen dguyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks

@dguyen
dguyen merged commit 5421b0d into documenso:main May 26, 2026
6 of 8 checks passed
scoobs-mystery-bytes pushed a commit to scoobs-mystery-bytes/documenso that referenced this pull request May 30, 2026

This branch was previously deployed

1 inactive deployment
Preview – stg-docs — 958583a2 Deployed May 26, 2026 by vercel[bot]
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.

3 participants