Skip to content

fix: return comparison result in reply name uniqueness check#77

Merged
iam-vipin merged 1 commit intoRocketChat:mainfrom
sezallagwal:fix/reply-name-uniqueness-validation
Mar 30, 2026
Merged

fix: return comparison result in reply name uniqueness check#77
iam-vipin merged 1 commit intoRocketChat:mainfrom
sezallagwal:fix/reply-name-uniqueness-validation

Conversation

@sezallagwal
Copy link
Copy Markdown
Contributor

Bug

In ReplyStorage.ts, the isUniqueReplyName method has a no-op comparison:

if (replyFound && replyId) {
    replyFound.id === replyId;  // comparison result is discarded!
    return true;                // always returns true
}

This means when editing a reply, the uniqueness check always passes — allowing a user to rename a reply to a name that's already used by another reply.

Fix

Return the comparison result directly:

if (replyFound && replyId) {
    return replyFound.id === replyId;  // true only if it's the same reply
}

This correctly returns true if the found reply is the same one being edited (user keeping their own name) and false if a different reply already has that name (blocking the duplicate)

Testing

  • Create two replies with different names (e.g., "Hello" and "Goodbye")
  • Edit "Hello" and change its name to "Goodbye"
  • Before fix: Edit is accepted, both replies now have the same name
  • After fix: Error is shown, edit is rejected

The isUniqueReplyName method had a bug where the comparison
replyFound.id === replyId was a standalone expression whose result
was discarded, followed by unconditionally returning true. This
allowed users to rename a reply to a name already used by another
reply, bypassing the uniqueness validation.

Fix: return the comparison result directly so the method correctly
returns false when a different reply already has that name.
@iam-vipin iam-vipin merged commit 558beee into RocketChat:main Mar 30, 2026
1 check passed
@sezallagwal sezallagwal deleted the fix/reply-name-uniqueness-validation branch March 30, 2026 09:22
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.

2 participants