RocketChat / RocketChat/EmbeddedChat

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

Open
#1,144 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
165
Forks
381
Avg merge
1d 2h
Merged PRs (30d)
1

Description

This PR fixes a crash that occurs when a user types an unknown slash command (e.g., /hello) and presses Enter.

Previously, entering a slash command that does not exist in the client-side commands list caused the application to crash with a TypeError. This PR ensures that the client handles unknown slash commands gracefully and aligns behavior with standard Rocket.Chat expectations.


Steps to Reproduce

  1. Open EmbeddedChat.
  2. Type /hello (or any unknown slash command) in the chat input.
  3. Press Enter.

Observed Behavior

The application crashes with the following error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'command')
    at CommandsList.js:33
    at HTMLDocument.handleKeyPress (CommandsList.js:54)
Image Image

Expected Behavior

  • The message /hello should be sent to the server.
  • The server should respond with No such command: /hello (standard Rocket.Chat behavior).
  • At a minimum, the client should not crash.
  • Add a defensive check to ensure selectedItem exists before accessing its properties.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in CommandsList.js, especially the keypress handling at the reported lines, and reproduce the issue by entering /hello and pressing Enter. Done means unknown commands no longer cause a TypeError, the message is sent for server handling, and the client remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.