{"record":{"id":"5977c79b6802edb8","repo":"Tencent/WeKnora","slug":"failed-to-create-request-w-5977c7","errorCode":null,"errorMessage":"failed to create request: %w","messagePattern":"failed to create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/ollama.go","lineNumber":101,"sourceCode":"\t}\n\tlogger.Infof(ctx, \"[WebSearch][Ollama] returned %d results\", len(results))\n\treturn results, nil\n}\n\nfunc (p *OllamaProvider) buildRequest(ctx context.Context, query string, maxResults int) (*http.Request, error) {\n\trequestBody := map[string]interface{}{\n\t\t\"query\":       query,\n\t\t\"max_results\": maxResults,\n\t}\n\n\tbodyBytes, err := json.Marshal(requestBody)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal request body: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", p.baseURL, bytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create request: %w\", err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer \"+p.apiKey)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", defaultUserAgentHeader)\n\n\treturn req, nil\n}\n\nfunc (p *OllamaProvider) doSearch(ctx context.Context, req *http.Request) ([]*types.WebSearchResult, error) {\n\tresp, err := p.client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/ollama.go#L83-L119","documentation":"HTTP client error in OllamaProvider.buildRequest: http.NewRequestWithContext failed to construct the POST to the provider's baseURL after the JSON body was marshaled. The %w retains the net/http cause; surfaced via Search as request-construction failure before any network I/O.","triggerScenarios":"Thrown at internal/infrastructure/web_search/ollama.go:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the Ollama baseURL constant/config is a valid absolute URL","Check for a context cancelled before Search was called"],"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"}