fix: prevent crash when typing unknown slash commands#1152
Open
vivekyadav-3 wants to merge 5 commits intoRocketChat:developfrom
Open
fix: prevent crash when typing unknown slash commands#1152vivekyadav-3 wants to merge 5 commits intoRocketChat:developfrom
vivekyadav-3 wants to merge 5 commits intoRocketChat:developfrom
Conversation
… resolve listener leaks
- 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
300f7ca to
e1a49f9
Compare
|
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.