Skip to content

fix: prevent crash when typing unknown slash commands#1152

Open
vivekyadav-3 wants to merge 17 commits intoRocketChat:developfrom
vivekyadav-3:fix/slash-command-crash
Open

fix: prevent crash when typing unknown slash commands#1152
vivekyadav-3 wants to merge 17 commits intoRocketChat:developfrom
vivekyadav-3:fix/slash-command-crash

Conversation

@vivekyadav-3
Copy link

Fixes #1144 – Prevent crash on unknown slash commands

While testing slash commands, I found a bug where entering a command that doesn’t exist (for example /hello) could crash the app with a TypeError.

Root cause

We were accessing properties on a command object without first confirming the command actually exists. When an unknown command was submitted, the code tried to read from undefined, which caused the crash.

Fix

Added a guard to ensure a command is selected before trying to use it:

if (selectedItem) {
handleCommandClick(selectedItem);
}

Now, if a user types an unknown slash command, the app safely ignores it instead of crashing.

… authentication, commands, and message tools
- Added encodeURIComponent() to properly encode user input before appending to URL query string
- Prevents special characters (&, ?, #, %) from breaking query parameters
- Fixes issue RocketChat#1149
- Changed typing status timeout from 15000ms to 10000ms
- Makes typing indicator more responsive and updates faster
- Improves real-time chat experience
- Added defensive check to ensure selectedItem exists before accessing properties
- Prevents TypeError when user types commands not in the filtered list
- Fixes issue RocketChat#1144
Copilot AI review requested due to automatic review settings February 11, 2026 15:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Bug : Crash when typing unknown slash command (e.g., /hello)

1 participant