Skip to content

codedb_remote: reject empty query on actions that consume it#316

Merged
justrach merged 1 commit intorelease/0.2.579from
fix/remote-require-query
Apr 25, 2026
Merged

codedb_remote: reject empty query on actions that consume it#316
justrach merged 1 commit intorelease/0.2.579from
fix/remote-require-query

Conversation

@justrach
Copy link
Copy Markdown
Owner

Problem

`codedb_remote action=search` without a `query` argument silently sends `q=` (empty string) to the remote. The remote returns either an empty result set or a confusing error, and the user can't tell whether their search was genuinely empty or malformed. Same applies to `action=symbol` and `action=outline` on the wiki backend.

Found during triage of open issues while I was looking at #278 and #304 — this is a separate bug the validation I was auditing didn't catch.

Fix

Validate that `query` is non-empty before building URLs, for actions that actually consume it:

  • `search` (both backends) → requires query
  • `symbol` (wiki backend) → requires query
  • `outline` (wiki backend) → requires query (the file path)
  • `tree` / `meta` / `policy` → unchanged (these legitimately take no query)

Error messages are specific so the caller knows which field to supply:

```
error: action 'search' requires a non-empty 'query' (the search text)
error: action 'symbol' requires a non-empty 'query' (the identifier name to look up)
error: action 'outline' requires a non-empty 'query' (the file path to outline)
```

Verified via MCP stdio

```
codedb_remote {"repo":"x","action":"search"}
→ error with guidance
codedb_remote {"repo":"x","action":"symbol","backend":"wiki"}
→ error with guidance
codedb_remote {"repo":"sinclairzx81/typebox","action":"tree","backend":"wiki"}
→ succeeds (unchanged, 1.5s)
codedb_remote {"repo":"rust-lang/rust","action":"symbol","query":"HashMap","backend":"wiki"}
→ 25 results (unchanged)
```

Not a regression

The missing-query case was already broken before my wiki backend landed; `codedb_remote action=search` without a query has always silently sent an empty q= to codegraff. This just surfaces the failure with a useful error instead.

🤖 Generated with Claude Code

Before this change, calling codedb_remote with action=search (or
action=symbol/outline on the wiki backend) but no 'query' argument
silently sent `q=` to the remote. codegraff.com would return an empty
result set or an unhelpful error, and users couldn't tell whether
their search was genuinely empty or the request was malformed.

Fail fast with a pointer at the missing field:

  error: action 'search' requires a non-empty 'query' (the search text)
  error: action 'symbol' requires a non-empty 'query' (the identifier name to look up)
  error: action 'outline' requires a non-empty 'query' (the file path to outline)

tree / meta / policy are unchanged (they legitimately take no query).

Verified via the MCP stdio interface:
  tools/call codedb_remote {"repo":"x","action":"search"}
    → error with guidance
  tools/call codedb_remote {"repo":"x","action":"symbol","backend":"wiki"}
    → error with guidance
  tools/call codedb_remote {"repo":"x","action":"tree","backend":"wiki"}
    → succeeds (unchanged)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 484596 513892 +6.05% OK
codedb_changes 56459 62166 +10.11% FAIL
codedb_deps 8717 9449 +8.40% OK
codedb_edit 4869 5238 +7.58% OK
codedb_find 65371 72614 +11.08% FAIL
codedb_hot 98517 100514 +2.03% OK
codedb_outline 243960 239085 -2.00% OK
codedb_read 84792 84733 -0.07% OK
codedb_search 174082 178969 +2.81% OK
codedb_snapshot 2616112 2602848 -0.51% OK
codedb_status 220670 211223 -4.28% OK
codedb_symbol 59472 63317 +6.47% OK
codedb_tree 82432 81908 -0.64% OK
codedb_word 69774 67853 -2.75% OK

@justrach justrach merged commit a514ea8 into release/0.2.579 Apr 25, 2026
1 check passed
@justrach justrach deleted the fix/remote-require-query branch April 27, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant