Skip to content

mcp: codedb_ls reports 'no entries' (exit 0) for paths that are not in the index #576

@justrach

Description

@justrach

Problem

codedb ls nonexistent/dir prints no entries and exits 0 — indistinguishable from a real-but-empty directory. An index only knows a directory through the files under it, so an empty listing for a non-empty prefix always means the path is not indexed; the tool should say so, and the CLI bridge should exit non-zero (finishCli already keys on the error: prefix). From the 2026-06-10 re-audit error-UX sweep.

Failing Test

A test in src/test_mcp.zig (named after this issue number once assigned): codedb_ls path:"nonexistent/dir" must emit error: no indexed files under 'nonexistent/dir' while path:"src" still lists entries. Verified failing on release/0.2.5825: 108/109 ('no entries').

Expected

Empty listing + non-empty prefix → error: no indexed files under '<path>' — check the path (codedb_tree shows the layout); empty prefix (project root with zero files) keeps no entries.

Fix

One branch in handleLs (src/mcp.zig).

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