Skip to content

fix: slash command params silently truncated at first line break#41325

Open
dsaicharan072-cmyk wants to merge 1 commit into
RocketChat:developfrom
dsaicharan072-cmyk:fix/slash-command-multiline-truncation
Open

fix: slash command params silently truncated at first line break#41325
dsaicharan072-cmyk wants to merge 1 commit into
RocketChat:developfrom
dsaicharan072-cmyk:fix/slash-command-multiline-truncation

Conversation

@dsaicharan072-cmyk

@dsaicharan072-cmyk dsaicharan072-cmyk commented Jul 11, 2026

Copy link
Copy Markdown

The client-side parse() helper in processSlashCommand.ts used the regex /^/([^\s]+)(.)/ without the dotall flag. Because (.) stops at \n by default, any text typed after a Shift+Enter in the composer was silently dropped before it reached the command handler.

Fix: add the /s (dotall) flag so (.*) matches across newlines.

The server-side parser (apps/meteor/lib/utils/parseParameters.ts) already handles multi-line params correctly; this change makes the client-side path consistent with it.

Closes: #41324

Summary by CodeRabbit

  • Bug Fixes

    • Fixed slash command parameters being truncated when the triggering message contains line breaks.
    • Multi-line and quoted parameters are now fully preserved and forwarded to the command handler.
  • Tests

    • Added Jest coverage for single-line, multi-line, and quoted multi-line slash command parameters.

@dsaicharan072-cmyk dsaicharan072-cmyk requested a review from a team as a code owner July 11, 2026 12:55
@dionisio-bot

dionisio-bot Bot commented Jul 11, 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 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4adc251

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

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

@CLAassistant

CLAassistant commented Jul 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eec71a98-39fc-45fb-a450-2b9ac5b6119e

📥 Commits

Reviewing files that changed from the base of the PR and between 3f0bb58 and 4adc251.

📒 Files selected for processing (1)
  • .changeset/fix-slash-command-multiline-truncation.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fix-slash-command-multiline-truncation.md

Walkthrough

The client slash-command parser now preserves parameters across newline characters. Tests verify single-line, multiline, and quoted multiline payloads, and a patch changeset documents the fix.

Changes

Multiline slash command parsing

Layer / File(s) Summary
Enable multiline parameter capture
apps/meteor/client/lib/chats/flows/processSlashCommand.ts
The parser regex now uses the dotall flag so command parameters include newline characters.
Validate command payload preservation
apps/meteor/client/lib/chats/flows/processSlashCommand.spec.ts, .changeset/fix-slash-command-multiline-truncation.md
Tests verify complete single-line, multiline, and quoted multiline parameters in the REST request, while the changeset documents the patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: type: bug

Suggested reviewers: d-gubert, KevLehman, ggazzo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: preserving slash command params past the first line break.
Linked Issues check ✅ Passed The dotall regex change and new test address the reported client-side truncation and match the issue requirements.
Out of Scope Changes check ✅ Passed The changes are limited to the slash-command fix, its test, and a changeset note, with no unrelated code paths.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 3 files

Re-trigger cubic

The client-side parse() helper in processSlashCommand.ts used the regex
/^\/([^\s]+)(.*)/ without the dotall flag. Because (.*) stops at \n by
default, any text typed after a Shift+Enter in the composer was silently
dropped before it reached the command handler.

Fix: add the /s (dotall) flag so (.*) matches across newlines.

The server-side parser (apps/meteor/lib/utils/parseParameters.ts) already
handles multi-line params correctly; this change makes the client-side
path consistent with it.

Closes: RocketChat#41324
@dsaicharan072-cmyk dsaicharan072-cmyk force-pushed the fix/slash-command-multiline-truncation branch from 3f0bb58 to 4adc251 Compare July 11, 2026 13:02
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.

Web client silently discards slash command text after the first line break before it reaches the command handler

2 participants