Tencent/WeKnora · error

base_url is required for SearXNG provider

Error message

base_url is required for SearXNG provider

What it means

ValidateSearxngBaseURL rejects an empty (after trimming) SearXNG base_url. The check is shared between parameter validation (save) and the provider constructor (use) so both paths fail identically and early.

Source

Thrown at internal/infrastructure/web_search/searxng.go:43

//
// Unlike commercial providers, SearXNG is self-hosted, so the instance URL is
// supplied by the tenant via WebSearchProviderParameters.BaseURL. The URL is
// validated with utils.ValidateURLForSSRF; private/loopback hosts must be added
// to the SSRF_WHITELIST environment variable.
type SearxngProvider struct {
	client           *http.Client
	baseURL          string
	lastUnresponsive [][]string
}

// ValidateSearxngBaseURL validates a SearXNG instance URL: must be a non-empty,
// absolute http(s) URL, and must pass the SSRF whitelist check. Shared between
// the service-layer parameter validation and the provider constructor so that
// "save" and "use" never disagree.
func ValidateSearxngBaseURL(rawURL string) error {
	base := strings.TrimSpace(rawURL)
	if base == "" {
		return fmt.Errorf("base_url is required for SearXNG provider")
	}
	parsed, err := url.Parse(base)
	if err != nil || parsed.Scheme == "" || parsed.Host == "" {
		return fmt.Errorf("invalid SearXNG base_url: must be an absolute http(s) URL")
	}
	if parsed.Scheme != "http" && parsed.Scheme != "https" {
		return fmt.Errorf("invalid SearXNG base_url scheme: %s", parsed.Scheme)
	}
	if parsed.RawQuery != "" || parsed.Fragment != "" {
		return fmt.Errorf("invalid SearXNG base_url: must not contain query or fragment")
	}
	if err := utils.ValidateURLForSSRF(base); err != nil {
		return fmt.Errorf("invalid SearXNG base_url: %w", err)
	}
	return nil
}

// NewSearxngProvider builds a SearXNG provider from tenant parameters.

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set base_url in the provider parameters, e.g. https://searx.example.com
  2. Verify the config key spelling matches what the code reads (base_url)
  3. Trim whitespace; a value of only spaces counts as empty
  4. Validate config at save time with ValidateSearxngBaseURL to catch it early

Example fix

// before
params := types.WebSearchProviderParameters{Type: "searxng"} // base_url empty
// after
params := types.WebSearchProviderParameters{Type: "searxng", BaseURL: "https://searx.example.com"}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(providerParams.BaseURL) == "" {
    return errors.New("searxng provider requires a non-empty base_url")
}
// or reuse the library check
if err := web_search.ValidateSearxngBaseURL(providerParams.BaseURL); err != nil { return err }

Try / catch

provider, err := web_search.NewSearxngProvider(params)
if err != nil {
    if strings.Contains(err.Error(), "base_url is required") {
        return fmt.Errorf("configuration incomplete: set base_url for the SearXNG provider")
    }
    return err
}

Prevention

When it happens

Trigger: NewSearxngProvider constructed with params.BaseURL == "" or whitespace-only, or saving a SearXNG provider config with base_url left blank.

Common situations: User created a SearXNG provider but never filled the base_url field, YAML key misspelled so the field reads empty (e.g. base-url vs base_url), template rendering produced an empty value.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/55f14ced4c179c22. Report an issue: GitHub.