codedb_remote: reject empty query on actions that consume it#316
Merged
justrach merged 1 commit intorelease/0.2.579from Apr 25, 2026
Merged
codedb_remote: reject empty query on actions that consume it#316justrach merged 1 commit intorelease/0.2.579from
justrach merged 1 commit intorelease/0.2.579from
Conversation
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>
Benchmark Regression ReportThreshold: 10.00%
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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