Skip to content

Command Sender Fails With Unclear Error when Single Quotes are Used #3550

Description

@shonigmann

Describe the bug

A member on our team recently ran into issues where the Command Sender would reject cmd() calls using single quotes instead of double quotes. The team member expected both single and double quotes to be treated equivalently and was surprised to see errors confusingly specifying that not enough inputs are provided (e.g. Error sending undefined due to RuntimeError: ERROR: Invalid number of arguments (0) passed to get_cmd_hazardous()).

The syntax highlighting appears treat both single and double quotes as strings, and we expect python and ruby to treat simple strings with single or double quotes equivalently as well

From claude's review of 7.2.0:

The bug is clear. At CommandSender.vue:401-403, when stripping the cmd("...") wrapper, the code only looks for double quotes ("). With single quotes, indexOf('"') returns -1, so firstQuote + 1 = 0 and lastQuote - firstQuote - 1 = -1 - (-1) - 1 = -1... 
let me verify what substr(0, -1) does:
  - firstQuote = -1 → firstQuote + 1 = 0
  - lastQuote = -1 → lastQuote - firstQuote - 1 = -1 - (-1) - 1 = -1
  - command.substr(0, -1) → empty string ""
So sendCmd("") is called, which explains why get_cmd_hazardous() gets 0 arguments — the command string is empty.
The fix is to handle single quotes in the same block

To Reproduce

cmd('SC NOOP')

fails

cmd("SC NOOP")

succeeds

Image

Expected behavior

either:

  • both single and double quotes are supported
  • syntax highlighting or error messages clearly inform users that single quotes are not acceptable

Screenshots

No response

OS

No response

OpenC3 COSMOS Version

6.4.2 and 7.2.0

Browser

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageMore information is needed

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions