fix(tools): reject empty repo/name identifier at tool layer (#37)

An empty required repo identifier built a trailing-empty path segment
(`/api/v1/repos/{owner}/`) and leaked gitea's bare 404. parseArgs now
validates, via reflection, that `repo`/`name` string args are non-empty and
returns a typed ErrValidation naming the field. Optional identifiers (e.g.
code_search's owner-wide fan-out `repo`) opt out with `,omitempty`. `owner` is
already enforced by the allowlist check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-03 22:47:05 +02:00
co-authored by Claude Opus 4.8
parent 9f12db3d94
commit e0bede0547
3 changed files with 75 additions and 3 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ func (t *CodeSearch) Descriptor() registry.ToolDescriptor {
type codeSearchArgs struct {
Q string `json:"q"`
Owner string `json:"owner"`
Repo string `json:"repo"`
Repo string `json:"repo,omitempty"` // optional: empty => owner-wide fan-out (#37 opt-out)
Page int `json:"page"`
Limit int `json:"limit"`
}