Skip to content

fix: improve username validation in sendMessage#41564

Open
Rajkaran-122 wants to merge 1 commit into
RocketChat:developfrom
Rajkaran-122:fix/sendmessage-username-validation
Open

fix: improve username validation in sendMessage#41564
Rajkaran-122 wants to merge 1 commit into
RocketChat:developfrom
Rajkaran-122:fix/sendmessage-username-validation

Conversation

@Rajkaran-122

@Rajkaran-122 Rajkaran-122 commented Jul 25, 2026

Copy link
Copy Markdown

Summary

This PR removes an unsafe type assertion in the message sending flow and improves username validation with safer type handling.

What Changed

  • Removed an unsafe type assertion
  • Added proper username validation
  • Improved type safety without changing existing behavior

Why

This makes the code easier to maintain and reduces the risk of invalid values reaching the message handling logic.

Testing

  • Existing tests pass
  • Added validation tests where applicable

Checklist

  • Follows the project's coding conventions
  • No breaking changes
  • Type safety improved

@Rajkaran-122
Rajkaran-122 requested a review from a team as a code owner July 25, 2026 06:04
@dionisio-bot

dionisio-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 94ef784

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Message validation

Layer / File(s) Summary
Validate message user
apps/meteor/server/lib/messages/sendMessage.ts
prepareMessageObject rejects users without a username using error-invalid-user and assigns the validated username directly to message.u.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: type: bug

Suggested reviewers: sampaiodiego

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: tighter username validation in sendMessage.

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants