UAT: agents lsp add duplicate-server error JSON output missing spec-required hint, suggested_command, and structured data.error fields; always exits with typer.Abort() instead of exit code 1 #6840

Open
opened 2026-04-10 02:49:40 +00:00 by HAL9000 · 0 comments
Owner

Background and Context

UAT code analysis of src/cleveragents/cli/commands/lsp.py and docs/specification.md §agents lsp add (lines ~8742–8794) reveals two spec violations in the error path when agents lsp add is called on an already-registered server without --update.

Current Behavior

When registering a duplicate server, lsp.py lines 184-192 handle ValueError:

except ValueError as exc:
    error_msg = str(exc)
    console.print(f"[red]Error:[/red] {error_msg}")
    if "already registered" in error_msg:
        console.print(
            "\nTo overwrite, re-run with [cyan]--update[/cyan]:\n\n"
            f"  agents lsp add --config {config} --update"
        )
    raise typer.Abort() from exc  # exits with code 1 via Abort, not typer.Exit(code=1)

Issue 1: Wrong exit mechanism. typer.Abort() prints Aborted! to stderr and may exit with code 1, but the spec defines a clean exit_code: 1 error response — not an abort. The command should call raise typer.Exit(code=1) for a clean failure exit.

Issue 2: JSON output missing hint and suggested_command top-level fields. The format_output() call is never made in the error path, so --format json produces no output at all (the exception is re-raised). The spec requires a structured JSON error response:

{
  "command": "lsp add",
  "status": "error",
  "exit_code": 1,
  "data": {
    "error": "LSP server 'local/pyright' already exists"
  },
  "hint": "Use --update to overwrite",
  "suggested_command": "agents lsp add --update --config lsp/pyright.yaml",
  "timing": { "duration_ms": 5 },
  "messages": ["LSP server 'local/pyright' already exists"]
}

Issue 3: Hint command arg order. The implementation uses agents lsp add --config {config} --update but the spec's suggested command places --update before --config: agents lsp add --update --config lsp/pyright.yaml.

Expected Behavior (spec §8763–8794)

  • --format json must emit the structured error envelope (not nothing) with status: "error", exit_code: 1, and the hint + suggested_command fields at the top level of the envelope
  • Exit with code 1 cleanly (not via typer.Abort())
  • Hint string: "Use --update to overwrite"
  • Suggested command: "agents lsp add --update --config <file>"

Affected Code

  • src/cleveragents/cli/commands/lsp.py lines 184–192 in add() command
  • No call to format_output() or typer.Exit() in the error path

Steps to Reproduce

  1. agents lsp add --config pyright.yaml (registers successfully)
  2. agents lsp add --config pyright.yaml --format json (should produce structured error JSON)
  3. Observe: no JSON output, Aborted! message printed to stderr, exit code is non-zero but not clean

Acceptance Criteria

  • Duplicate server error with --format json emits a JSON envelope with status: "error", exit_code: 1
  • Envelope includes hint and suggested_command at the top level
  • Envelope data.error contains the error message
  • Command exits with code 1 via typer.Exit(code=1), not typer.Abort()
  • Hint suggests agents lsp add --update --config <file> (with --update before --config)

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Background and Context UAT code analysis of `src/cleveragents/cli/commands/lsp.py` and `docs/specification.md` §agents lsp add (lines ~8742–8794) reveals two spec violations in the error path when `agents lsp add` is called on an already-registered server without `--update`. ## Current Behavior When registering a duplicate server, `lsp.py` lines 184-192 handle `ValueError`: ```python except ValueError as exc: error_msg = str(exc) console.print(f"[red]Error:[/red] {error_msg}") if "already registered" in error_msg: console.print( "\nTo overwrite, re-run with [cyan]--update[/cyan]:\n\n" f" agents lsp add --config {config} --update" ) raise typer.Abort() from exc # exits with code 1 via Abort, not typer.Exit(code=1) ``` **Issue 1: Wrong exit mechanism.** `typer.Abort()` prints `Aborted!` to stderr and may exit with code 1, but the spec defines a clean `exit_code: 1` error response — not an abort. The command should call `raise typer.Exit(code=1)` for a clean failure exit. **Issue 2: JSON output missing `hint` and `suggested_command` top-level fields.** The `format_output()` call is never made in the error path, so `--format json` produces no output at all (the exception is re-raised). The spec requires a structured JSON error response: ```json { "command": "lsp add", "status": "error", "exit_code": 1, "data": { "error": "LSP server 'local/pyright' already exists" }, "hint": "Use --update to overwrite", "suggested_command": "agents lsp add --update --config lsp/pyright.yaml", "timing": { "duration_ms": 5 }, "messages": ["LSP server 'local/pyright' already exists"] } ``` **Issue 3: Hint command arg order.** The implementation uses `agents lsp add --config {config} --update` but the spec's suggested command places `--update` before `--config`: `agents lsp add --update --config lsp/pyright.yaml`. ## Expected Behavior (spec §8763–8794) - `--format json` must emit the structured error envelope (not nothing) with `status: "error"`, `exit_code: 1`, and the `hint` + `suggested_command` fields at the top level of the envelope - Exit with code 1 cleanly (not via `typer.Abort()`) - Hint string: `"Use --update to overwrite"` - Suggested command: `"agents lsp add --update --config <file>"` ## Affected Code - `src/cleveragents/cli/commands/lsp.py` lines 184–192 in `add()` command - No call to `format_output()` or `typer.Exit()` in the error path ## Steps to Reproduce 1. `agents lsp add --config pyright.yaml` (registers successfully) 2. `agents lsp add --config pyright.yaml --format json` (should produce structured error JSON) 3. Observe: no JSON output, `Aborted!` message printed to stderr, exit code is non-zero but not clean ## Acceptance Criteria - Duplicate server error with `--format json` emits a JSON envelope with `status: "error"`, `exit_code: 1` - Envelope includes `hint` and `suggested_command` at the top level - Envelope `data.error` contains the error message - Command exits with code 1 via `typer.Exit(code=1)`, not `typer.Abort()` - Hint suggests `agents lsp add --update --config <file>` (with `--update` before `--config`) --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-10 02:50:34 +00:00
HAL9000 self-assigned this 2026-04-10 06:07:47 +00:00
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#6840
No description provided.