{"record":{"id":"910a7e3faf214f33","repo":"Tencent/WeKnora","slug":"failed-to-execute-exa-request-w","errorCode":null,"errorMessage":"failed to execute Exa request: %w","messagePattern":"failed to execute Exa request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/exa.go","lineNumber":97,"sourceCode":"\t\tContents: exaContents{\n\t\t\tHighlights: true,\n\t\t\tText:       p.includeText,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal Exa request: %w\", err)\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, p.baseURL, bytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create Exa request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"x-api-key\", p.apiKey)\n\n\tlogger.Infof(ctx, \"[WebSearch][Exa] query=%q maxResults=%d url=%s\", query, maxResults, p.baseURL)\n\tresp, err := p.client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to execute Exa request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, maxExaResponseBytes))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read Exa response: %w\", err)\n\t}\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {\n\t\tlogger.Warnf(ctx, \"[WebSearch][Exa] API returned status %d: %s\", resp.StatusCode, string(body))\n\t\treturn nil, fmt.Errorf(\"exa API returned status %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar data exaSearchResponse\n\tif err := json.Unmarshal(body, &data); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal Exa response: %w\", err)\n\t}\n\tif data.Error != \"\" {\n\t\treturn nil, fmt.Errorf(\"exa API error: %s\", data.Error)\n\t}","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/exa.go#L79-L115","documentation":"Wraps errors from p.client.Do(req) when the HTTP round-trip to the Exa API fails before a response is returned. Causes include DNS failures, unreachable host, TLS problems, client timeout, or context cancellation during the request.","triggerScenarios":"Calling Search when the network cannot reach api.exa.ai, the configured proxy is down or wrong, the client timeout (defaultExaTimeout) expires, or ctx is canceled mid-request.","commonSituations":"No egress to api.exa.ai from a private cluster, invalid proxyURL parameter, firewall blocking the domain, slow Exa responses exceeding the client timeout, revoked DNS in rotating environments.","solutions":["Confirm outbound connectivity to api.exa.ai:443 from the deployment","Check/fix the proxyURL in provider parameters","Increase defaultExaTimeout if large searches time out","Add bounded retry with backoff for transient failures","Inspect the unwrapped *url.Error for timeout vs connection specifics"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"api.exa.ai:443\", 3*time.Second)\nif err != nil {\n    return fmt.Errorf(\"no egress to api.exa.ai: %w\", err)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"results, err := provider.Search(ctx, query, 10, false)\nif err != nil {\n    var ne net.Error\n    if errors.As(err, &ne) && ne.Timeout() || errors.Is(err, context.DeadlineExceeded) {\n        return retryWithBackoff(ctx, query)\n    }\n    return fallbackProvider.Search(ctx, query, 10, false)\n}","preventionTips":["Allow-list api.exa.ai in firewall/egress rules","Verify proxy settings with a smoke request at startup","Size the client timeout to expected worst-case search latency","Retry idempotent searches with exponential backoff"],"tags":["network","http","timeout","proxy","go"],"backgroundTag":"http-request-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}