{"record":{"id":"55f14ced4c179c22","repo":"Tencent/WeKnora","slug":"base-url-is-required-for-searxng-provider","errorCode":null,"errorMessage":"base_url is required for SearXNG provider","messagePattern":"base_url is required for SearXNG provider","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/searxng.go","lineNumber":43,"sourceCode":"//\n// Unlike commercial providers, SearXNG is self-hosted, so the instance URL is\n// supplied by the tenant via WebSearchProviderParameters.BaseURL. The URL is\n// validated with utils.ValidateURLForSSRF; private/loopback hosts must be added\n// to the SSRF_WHITELIST environment variable.\ntype SearxngProvider struct {\n\tclient           *http.Client\n\tbaseURL          string\n\tlastUnresponsive [][]string\n}\n\n// ValidateSearxngBaseURL validates a SearXNG instance URL: must be a non-empty,\n// absolute http(s) URL, and must pass the SSRF whitelist check. Shared between\n// the service-layer parameter validation and the provider constructor so that\n// \"save\" and \"use\" never disagree.\nfunc ValidateSearxngBaseURL(rawURL string) error {\n\tbase := strings.TrimSpace(rawURL)\n\tif base == \"\" {\n\t\treturn fmt.Errorf(\"base_url is required for SearXNG provider\")\n\t}\n\tparsed, err := url.Parse(base)\n\tif err != nil || parsed.Scheme == \"\" || parsed.Host == \"\" {\n\t\treturn fmt.Errorf(\"invalid SearXNG base_url: must be an absolute http(s) URL\")\n\t}\n\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\treturn fmt.Errorf(\"invalid SearXNG base_url scheme: %s\", parsed.Scheme)\n\t}\n\tif parsed.RawQuery != \"\" || parsed.Fragment != \"\" {\n\t\treturn fmt.Errorf(\"invalid SearXNG base_url: must not contain query or fragment\")\n\t}\n\tif err := utils.ValidateURLForSSRF(base); err != nil {\n\t\treturn fmt.Errorf(\"invalid SearXNG base_url: %w\", err)\n\t}\n\treturn nil\n}\n\n// NewSearxngProvider builds a SearXNG provider from tenant parameters.","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/searxng.go#L25-L61","documentation":"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.","triggerScenarios":"NewSearxngProvider constructed with params.BaseURL == \"\" or whitespace-only, or saving a SearXNG provider config with base_url left blank.","commonSituations":"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.","solutions":["Set base_url in the provider parameters, e.g. https://searx.example.com","Verify the config key spelling matches what the code reads (base_url)","Trim whitespace; a value of only spaces counts as empty","Validate config at save time with ValidateSearxngBaseURL to catch it early"],"exampleFix":"// before\nparams := types.WebSearchProviderParameters{Type: \"searxng\"} // base_url empty\n// after\nparams := types.WebSearchProviderParameters{Type: \"searxng\", BaseURL: \"https://searx.example.com\"}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(providerParams.BaseURL) == \"\" {\n    return errors.New(\"searxng provider requires a non-empty base_url\")\n}\n// or reuse the library check\nif err := web_search.ValidateSearxngBaseURL(providerParams.BaseURL); err != nil { return err }","typeGuard":null,"tryCatchPattern":"provider, err := web_search.NewSearxngProvider(params)\nif err != nil {\n    if strings.Contains(err.Error(), \"base_url is required\") {\n        return fmt.Errorf(\"configuration incomplete: set base_url for the SearXNG provider\")\n    }\n    return err\n}","preventionTips":["Make base_url a required field in your config schema/UI","Validate with ValidateSearxngBaseURL at config save time","Check for YAML key typos (base_url vs base-url)","Trim user input before storing provider params"],"tags":["validation","configuration","searxng","missing-field"],"backgroundTag":"missing-required-config","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}