JuliusBrussee/caveman · error
request URL is missing
Error message
request URL is missing
What it means
Thrown by ValidateRequestPath when it is called with a nil *url.URL. This pre-adapter validation gate rejects ambiguous path encodings before adapter selection; a nil URL means the caller has no request path to validate, so it fails closed instead of skipping validation.
Source
Thrown at proxy/providers/openaicompat/openaicompat.go:251
return nil, err
}
if !strings.HasPrefix(req.URL.Path, a.prefix+"/") {
return nil, fmt.Errorf("compat route %q does not match prefix %q", req.URL.Path, a.prefix+"/")
}
path := strings.TrimPrefix(req.URL.Path, a.prefix)
base.Path = joinCompatPath(base.Path, path)
base.RawPath = ""
base.RawQuery = joinCompatQuery(base.RawQuery, req.URL.RawQuery)
return base, nil
}
// ValidateRequestPath rejects ambiguous path encodings before adapter selection.
// Gateways call this with the original URL (including RawPath), while the
// adapter MatchRoute/ResolveUpstreamURL checks provide a second fail-closed
// boundary for direct callers.
func ValidateRequestPath(u *url.URL) error {
if u == nil {
return fmt.Errorf("request URL is missing")
}
if !strings.HasPrefix(u.Path, "/compat/") {
return nil
}
return validateCompatPath(u.Path, u.RawPath)
}
func validateCompatPath(path, rawPath string) error {
if !strings.HasPrefix(path, "/compat/") {
return nil
}
if err := validatePathComponents(path, rawPath); err != nil {
return fmt.Errorf("compat route path rejected: %w", err)
}
return nil
}
func validatePathComponents(path, rawPath string) error {View on GitHub (pinned to 27d5a3981a)
Solutions
- Pass the request's parsed URL: ValidateRequestPath(r.URL) on a non-nil *http.Request.
- Add a nil check at the call site and reject the request earlier (400/502) if the URL could not be established.
- In tests, build the URL with url.Parse or httptest.NewRequest rather than leaving it nil.
Example fix
// before
if err := ValidateRequestPath(maybeNilURL); err != nil { ... }
// after
if r == nil || r.URL == nil {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
if err := ValidateRequestPath(r.URL); err != nil { ... } Defensive patterns
Strategy: validation
Validate before calling
if r == nil || r.URL == nil {
http.Error(w, "request URL missing", http.StatusBadRequest)
return
}
if err := openaicompat.ValidateRequestPath(r.URL); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
} Try / catch
Handle as a 400/500 boundary error and stop; no retry. Log where the nil URL came from if reachable.
Prevention
- Never call ValidateRequestPath with a value that wasn't obtained from a parsed *http.Request.
- Guard request middleware against nil r.URL before any handler runs.
- Unit-test the exported validator with both nil and valid URLs to lock the contract.
When it happens
Trigger: ValidateRequestPath(nil) — a gateway or direct caller passing a nil URL because the request failed to parse upstream, or test code exercising the validation boundary without constructing a URL.
Common situations: Middleware that forwards r.URL after a parsing step that can return nil; tests calling the exported validator directly; refactoring that changed the call site from r.URL to a variable that can be nil.
Related errors
- compat request URL is missing
- caveman agent: file path is required
- caveman agent: invalid tool name ${JSON.stringify(options.na
- caveman agent: unknown tool effect ${JSON.stringify(options.
- caveman agent: unknown tool result policy ${JSON.stringify(r
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/fb3c13ffda048dd2.
Report an issue: GitHub.