Skip to content

cli/mcp: leading flag silently binds as the positional name; empty symbol name is not a usage error #573

@justrach

Description

@justrach

Problem

Two argument-handling defects from the 2026-06-10 re-audit:

  1. runCliTool takes args[cmd_args_start] blindly as the positional, so codedb callers --max-results 3 indexFile reports "1 call sites for '--max-results'" — a silently wrong answer instead of a usage error. Affects every bridge command that takes a leading /.
  2. codedb_symbol with name: "" returns no results for: (trailing colon, blank name) instead of a usage error — codedb_callers already rejects empty names; symbol should mirror it.

Failing Test

test "issue-573: cli bridge must not bind a leading flag as the positional name" in src/test_mcp.zig (branch fix/issue-573-arg-ux): callers with argv [--max-results, 3, indexFile] must not report call sites for '--max-results' and must fall through to the callers <name> usage line; codedb_symbol name:"" must emit error: empty name. Verified failing on release/0.2.5825: 107/108.

Fix

  • runCliTool: a leading --prefixed arg is not bound as the positional — pos stays null and the command's existing usage error fires
  • handleSymbol: explicit empty-name guard mirroring callers

Also folded in: handleCallers count/print double-loop collapsed to a single filter pass (same predicates were duplicated; a future edit to one loop would silently desync the header count — flagged as a maintenance trap in the same audit). Behavior unchanged, guarded by issue-391/425/426/562 tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:p2Medium priority

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions