{"record":{"id":"818e70300bb54209","repo":"Tencent/WeKnora","slug":"create-ollama-http-client-w","errorCode":null,"errorMessage":"create Ollama HTTP client: %w","messagePattern":"create Ollama HTTP client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/ollama.go","lineNumber":40,"sourceCode":"\tdefaultOllamaResults      = 5\n\tmaxOllamaResults          = 10 // Ollama限制最多10个结果\n)\n\n// OllamaProvider implements web search using Ollama Cloud API\ntype OllamaProvider struct {\n\tclient  *http.Client\n\tbaseURL string\n\tapiKey  string\n}\n\n// NewOllamaProvider creates a new Ollama web search provider from parameters.\nfunc NewOllamaProvider(params types.WebSearchProviderParameters) (interfaces.WebSearchProvider, error) {\n\tif params.APIKey == \"\" {\n\t\treturn nil, fmt.Errorf(\"API key is required for Ollama provider\")\n\t}\n\tclient, err := NewSearchHTTPClient(defaultOllamaTimeout, params.ProxyURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create Ollama HTTP client: %w\", err)\n\t}\n\treturn &OllamaProvider{\n\t\tclient:  client,\n\t\tbaseURL: defaultOllamaWebSearchURL, // Hardcoded — not tenant-configurable\n\t\tapiKey:  params.APIKey,\n\t}, nil\n}\n\n// Name returns the provider name\nfunc (p *OllamaProvider) Name() string {\n\treturn \"ollama\"\n}\n\n// Search performs a web search using Ollama Cloud API\nfunc (p *OllamaProvider) Search(\n\tctx context.Context,\n\tquery string,\n\tmaxResults int,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/ollama.go#L22-L58","documentation":"Returned by NewOllamaProvider when NewSearchHTTPClient fails to construct the HTTP client — most commonly an invalid proxy_url that failed SSRF-aware validation, or the default transport not being *http.Transport.","triggerScenarios":"Thrown at internal/infrastructure/web_search/ollama.go:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the proxy_url format (scheme://host:port)","Remove the proxy setting if unnecessary","Verify the process default transport is unmodified"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}