Tencent/WeKnora · error
invalid proxy_url: scheme and host are required
Error message
invalid proxy_url: scheme and host are required
What it means
The proxy_url parsed successfully but lacks a scheme or a host, so it cannot be used as an HTTP proxy URL. This is a validation error distinct from parse failures; the URL syntax was fine but semantically incomplete.
Source
Thrown at internal/infrastructure/web_search/proxy.go:43
func NewSearchHTTPClient(timeout time.Duration, proxyURL string) (*http.Client, error) {
proxyURL = strings.TrimSpace(proxyURL)
def, ok := http.DefaultTransport.(*http.Transport)
if !ok {
return nil, fmt.Errorf("default HTTP transport is not *http.Transport")
}
t := def.Clone()
t.DialContext = utils.SSRFSafeDialContext
if proxyURL != "" {
if err := ValidateProxyURL(proxyURL); err != nil {
return nil, err
}
u, err := url.Parse(proxyURL)
if err != nil {
return nil, fmt.Errorf("invalid proxy_url: %w", err)
}
if u.Scheme == "" || u.Host == "" {
return nil, fmt.Errorf("invalid proxy_url: scheme and host are required")
}
t.Proxy = http.ProxyURL(u)
} else {
t.Proxy = http.ProxyFromEnvironment
}
cfg := utils.DefaultSSRFSafeHTTPClientConfig()
cfg.Timeout = timeout
return utils.NewSSRFSafeHTTPClientWithTransport(cfg, t), nil
}
View on GitHub (pinned to 988cbb0330)
Solutions
- Add the scheme: change "localhost:8080" to "http://localhost:8080"
- Ensure the host is present, not just a scheme
- Run ValidateProxyURL/url.Parse checks on config at startup, before provider creation
- For SOCKS, use socks5:// explicitly
Example fix
// before proxyURL := "10.0.0.5:3128" // after proxyURL := "http://10.0.0.5:3128"
Defensive patterns
Strategy: validation
Validate before calling
func hasSchemeAndHost(raw string) bool {
u, err := url.Parse(strings.TrimSpace(raw))
return err == nil && u.Scheme != "" && u.Host != ""
}
// usage: if proxyURL != "" && !hasSchemeAndHost(proxyURL) { ... reject ... } Try / catch
client, err := web_search.NewSearchHTTPClient(timeout, proxyURL)
if err != nil {
if strings.Contains(err.Error(), "scheme and host are required") {
return fmt.Errorf("proxy_url %q needs scheme and host, e.g. http://proxy:8080", proxyURL)
}
return err
} Prevention
- Always include the scheme (http://, https://, socks5://) in proxy config
- Add a UI/config-level regex check like ^[a-z][a-z0-9+.-]*://
- Normalize config values with strings.TrimSpace before use
- Document the expected format next to the proxy_url field
When it happens
Trigger: NewSearchHTTPClient called with values like "localhost:8080" (no scheme; url.Parse treats it as path-only), "/path/to/sock", or "" is allowed but "http://" (empty host) triggers this.
Common situations: Config values like "proxy.company.com:3128" without http://, YAML interpolation dropping the scheme, users entering only a hostname from proxy docs.
Related errors
- invalid proxy_url: %w
- invalid SearXNG base_url: must be an absolute http(s) URL
- invalid SearXNG base_url: must not contain query or fragment
- invalid sandbox type
- timeout cannot be negative
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/08c6361f126b63e8.
Report an issue: GitHub.