JuliusBrussee/caveman · error
provider has no configured upstream URL
Error message
provider %q has no configured upstream URL
What it means
Base.ResolveUpstreamURL determines the upstream target for a provider request from BaseURL or the per-request RouteContext.BaseURL. If, after route overrides, the base URL is empty/whitespace, there is no server to proxy to, so it errors naming the provider. This prevents building requests against a nil base.
Solutions
- Set the provider's BaseURL in configuration (e.g. https://api.openai.com)
- Populate RouteContext.BaseURL for per-route overrides instead of leaving it empty
- Verify config loading actually assigns the base URL field (don't shadow with "")
- Log/validate the provider config at startup so missing URLs are caught early
Example fix
// before
adapter := providers.Base{Provider: "openai"} // BaseURL unset
// after
adapter := providers.Base{Provider: "openai", BaseURL: "https://api.openai.com"} Defensive patterns
Strategy: validation
Validate before calling
func ensureBaseURL(b providers.Base, route providers.RouteContext) error {
url := route.BaseURL
if url == "" { url = b.BaseURL }
if strings.TrimSpace(url) == "" {
return fmt.Errorf("provider %q needs a BaseURL", b.Provider)
}
return nil
} Try / catch
u, err := adapter.ResolveUpstreamURL(ctx, req, route)
if err != nil && strings.Contains(err.Error(), "no configured upstream URL") {
// fail request with 500 + config guidance
} Prevention
- Validate provider config (BaseURL present) at startup, before serving traffic
- Never assign empty-string route overrides over valid defaults
- Add config schema validation requiring base_url for each provider
When it happens
Trigger: Calling a provider adapter whose BaseURL was never set and whose RouteContext.BaseURL is empty — e.g. constructing Base{} without configuration, or a route entry with a blank BaseURL field overriding a valid default with "".
Common situations: Config file missing the upstream/base-url key for a custom provider; stub/test adapters registered without a base URL; route table entries accidentally blank after refactoring config loading.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- compat route does not match default /compat/ mount
- compat route does not match prefix
- provider upstream URL must be absolute
- unsupported proxy protocol
- AbortError
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/292befc3ef0991a9.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/providers/adapter.go:468
for _, route := range b.Routes {
// Routes ending in '/' are explicit subtree mounts (for example
// /compat/ and /azure/). Every other route is exact. Treating all routes
// as prefixes made /v1/responses-anything and /v1/messages/unknown valid
// proxy surfaces, violating the gateway's closed route allowlist.
if path == route || strings.HasSuffix(route, "/") && strings.HasPrefix(path, route) {
return true
}
}
return false
}
func (b Base) ResolveUpstreamURL(ctx context.Context, req *http.Request, route RouteContext) (*url.URL, error) {
baseURL := b.BaseURL
if route.BaseURL != "" {
baseURL = route.BaseURL
}
if strings.TrimSpace(baseURL) == "" {
return nil, fmt.Errorf("provider %q has no configured upstream URL", b.Provider)
}
base, err := url.Parse(baseURL)
if err != nil {
return nil, err
}
if !base.IsAbs() || base.Hostname() == "" {
return nil, fmt.Errorf("provider %q upstream URL must be absolute", b.Provider)
}
path := req.URL.Path
for _, prefix := range []string{"/openai", "/anthropic", "/gemini", "/compat/stub", "/compat/openai-compatible"} {
path = strings.TrimPrefix(path, prefix)
}
if strings.HasPrefix(req.URL.Path, "/azure/") {
path = strings.TrimPrefix(req.URL.Path, "/azure")
}
base.Path = strings.TrimRight(base.Path, "/") + path
base.RawQuery = req.URL.RawQuery
return base, nilView on GitHub (pinned to 3ee70a1026)