BUG: Invalid command error message says "Invalid command" but spec/tests expect "No such command" #8625

Open
opened 2026-04-13 21:27:09 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(cli): change invalid command error message to match spec ("No such command")
  • Branch: fix/invalid-command-error-message

Background and Context

The CleverAgents CLI spec and BDD test features/cli_v2_parity.feature specifies that when an unknown/invalid command is passed to the CLI, the error message should contain "No such command". However, the current implementation in src/cleveragents/cli/main.py outputs "Error: Invalid command" instead.

Affected code (src/cleveragents/cli/main.py, lines 759-766):

if (
    args
    and not any(args[0] == cmd for cmd in valid_cmds)
    and not args[0].startswith("-")
):
    err_console.print(f"Error: Invalid command '{args[0]}'")
    err_console.print("Try 'cleveragents --help' for help.")
    return 2

BDD test (features/cli_v2_parity.feature, lines 6-10):

Scenario: Unknown command reports a helpful error
  When I run the CleverAgents CLI with "invalid-command"
  Then the CLI command should fail
  And the CLI output should contain "No such command"
  And the exit code should be 2

The test expects "No such command" but the implementation outputs "Error: Invalid command 'invalid-command'". This causes the BDD test to fail.

Current Behavior

When running agents invalid-command, the output is:

Error: Invalid command 'invalid-command'
Try 'cleveragents --help' for help.

Exit code: 2

Expected Behavior

When running agents invalid-command, the output should contain:

No such command 'invalid-command'

Exit code: 2

Acceptance Criteria

  • The error message for invalid commands contains "No such command" (matching the BDD test expectation)
  • The exit code remains 2 for invalid commands
  • The BDD test in features/cli_v2_parity.feature passes
  • The error message still includes the invalid command name for user clarity

Supporting Information

  • Affected file: src/cleveragents/cli/main.py (line 764)
  • BDD test: features/cli_v2_parity.feature (Scenario: "Unknown command reports a helpful error")
  • The fix is a one-line change to the error message string

Subtasks

  • Update the error message in src/cleveragents/cli/main.py line 764 from "Error: Invalid command '{args[0]}'" to "No such command '{args[0]}'"
  • Verify features/cli_v2_parity.feature BDD test passes
  • Run nox (all default sessions), fix any errors
  • Verify coverage >= 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor
Worker: [AUTO-UAT-8]

## Metadata - **Commit Message**: `fix(cli): change invalid command error message to match spec ("No such command")` - **Branch**: `fix/invalid-command-error-message` ## Background and Context The CleverAgents CLI spec and BDD test `features/cli_v2_parity.feature` specifies that when an unknown/invalid command is passed to the CLI, the error message should contain "No such command". However, the current implementation in `src/cleveragents/cli/main.py` outputs "Error: Invalid command" instead. **Affected code** (`src/cleveragents/cli/main.py`, lines 759-766): ```python if ( args and not any(args[0] == cmd for cmd in valid_cmds) and not args[0].startswith("-") ): err_console.print(f"Error: Invalid command '{args[0]}'") err_console.print("Try 'cleveragents --help' for help.") return 2 ``` **BDD test** (`features/cli_v2_parity.feature`, lines 6-10): ```gherkin Scenario: Unknown command reports a helpful error When I run the CleverAgents CLI with "invalid-command" Then the CLI command should fail And the CLI output should contain "No such command" And the exit code should be 2 ``` The test expects "No such command" but the implementation outputs "Error: Invalid command 'invalid-command'". This causes the BDD test to fail. ## Current Behavior When running `agents invalid-command`, the output is: ``` Error: Invalid command 'invalid-command' Try 'cleveragents --help' for help. ``` Exit code: 2 ## Expected Behavior When running `agents invalid-command`, the output should contain: ``` No such command 'invalid-command' ``` Exit code: 2 ## Acceptance Criteria - [ ] The error message for invalid commands contains "No such command" (matching the BDD test expectation) - [ ] The exit code remains 2 for invalid commands - [ ] The BDD test in `features/cli_v2_parity.feature` passes - [ ] The error message still includes the invalid command name for user clarity ## Supporting Information - Affected file: `src/cleveragents/cli/main.py` (line 764) - BDD test: `features/cli_v2_parity.feature` (Scenario: "Unknown command reports a helpful error") - The fix is a one-line change to the error message string ## Subtasks - [ ] Update the error message in `src/cleveragents/cli/main.py` line 764 from `"Error: Invalid command '{args[0]}'"` to `"No such command '{args[0]}'"` - [ ] Verify `features/cli_v2_parity.feature` BDD test passes - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor Worker: [AUTO-UAT-8]
Author
Owner

[AUTO-OWNR-1] Triage Decision (Cycle 6)

Status: Verified

MoSCoW: Should Have
Priority: Low

Rationale: The error message wording mismatch between the implementation ("Error: Invalid command") and the spec/BDD tests ("No such command") is a confirmed real bug. It causes the BDD test in features/cli_v2_parity.feature to fail. While this is a minor one-line fix with no architectural impact, it is a genuine spec compliance issue that should be resolved. It is classified as Should Have / Low Priority because it does not block any core functionality — the exit code and error behaviour are otherwise correct.

Next Steps: Update src/cleveragents/cli/main.py line 764 to change "Error: Invalid command '{args[0]}'" to "No such command '{args[0]}'". Verify the BDD test passes, run nox, confirm coverage ≥ 97%, and submit a PR to master on branch fix/invalid-command-error-message.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

## [AUTO-OWNR-1] Triage Decision (Cycle 6) **Status**: ✅ Verified **MoSCoW**: Should Have **Priority**: Low **Rationale**: The error message wording mismatch between the implementation (`"Error: Invalid command"`) and the spec/BDD tests (`"No such command"`) is a confirmed real bug. It causes the BDD test in `features/cli_v2_parity.feature` to fail. While this is a minor one-line fix with no architectural impact, it is a genuine spec compliance issue that should be resolved. It is classified as Should Have / Low Priority because it does not block any core functionality — the exit code and error behaviour are otherwise correct. **Next Steps**: Update `src/cleveragents/cli/main.py` line 764 to change `"Error: Invalid command '{args[0]}'"` to `"No such command '{args[0]}'"`. Verify the BDD test passes, run `nox`, confirm coverage ≥ 97%, and submit a PR to `master` on branch `fix/invalid-command-error-message`. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8625
No description provided.