Skip to content

Comments

fix: prevent crash when typing unknown slash commands#1152

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

fix: prevent crash when typing unknown slash commands#1152
vivekyadav-3 wants to merge 5 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.

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.

- Prevented crash on unknown slash commands in CommandsList\n- Improved command list visibility logic in useShowCommands\n- Fixed session state leaks by resetting user store on logout in EmbeddedChat\n- Removed hardcoded default emoji preview in EmojiPicker
@vivekyadav-3 vivekyadav-3 force-pushed the fix/slash-command-crash branch from 300f7ca to e1a49f9 Compare February 20, 2026 07:39
@CLAassistant
Copy link

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.

@vivekyadav-3
Copy link
Author

Hi! I just force-pushed to clean up this branch. It now strictly contains the 1-line null check to fix the crash. Sorry for the noise earlier! Ready for review when you are.

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)

3 participants