forgejo-mcp/operation/resource
Christoph Görn 1aa797ab7a
refactor: 🏗️ classify parse errors via sentinel ErrInvalidParams (-32602)
MapForgejoError previously classified HTTP results by substring
matching. Two failure modes: URIs/error bodies legitimately
containing "404"/"Forbidden" mis-classified, and parser errors of
shape "invalid URI: expected forgejo://..." fell through to -32603
because the existing "kind must be"/"index must be numeric"
substrings did not cover them.

Introduce resource.ErrInvalidParams sentinel; wrap every parser
return path with it (Parse{Owner,Repo,Commit,Issue,PR,Comment,Status},
parseForgejoURI, validateSHA). MapForgejoError now classifies via
errors.Is(err, ErrInvalidParams) before falling back to HTTP
substring matching for 403/404. Substring matching for 403/404
stays as a transition fallback because the SDK still surfaces
HTTP status only via formatted error strings.

Update handler tests that asserted Code == -32603 on parse errors
(set by forgejo-mcp-vzz) to assert -32602.

Closes forgejo-mcp-wgs.
Ref PR #172 review https://codeberg.org/goern/forgejo-mcp/pulls/172#issuecomment-16022165
2026-05-28 16:08:59 +02:00
..
bound.go feat: ✨ MCP resource templates — slices 1+2 (core framework + commit) 2026-05-28 14:31:55 +02:00
bound_test.go feat: ✨ MCP resource templates — slices 1+2 (core framework + commit) 2026-05-28 14:31:55 +02:00
doc.go feat: ✨ MCP resource templates — slices 1+2 (core framework + commit) 2026-05-28 14:31:55 +02:00
errors.go refactor: 🏗️ classify parse errors via sentinel ErrInvalidParams (-32602) 2026-05-28 16:08:59 +02:00
errors_test.go refactor: 🏗️ classify parse errors via sentinel ErrInvalidParams (-32602) 2026-05-28 16:08:59 +02:00
parse.go refactor: 🏗️ classify parse errors via sentinel ErrInvalidParams (-32602) 2026-05-28 16:08:59 +02:00
parse_test.go refactor: 🏗️ classify parse errors via sentinel ErrInvalidParams (-32602) 2026-05-28 16:08:59 +02:00
register.go feat: ✨ MCP resource templates — slices 1+2 (core framework + commit) 2026-05-28 14:31:55 +02:00