{"record":{"id":"9af98c801bb9cadd","repo":"Tencent/WeKnora","slug":"execute-request-w","errorCode":null,"errorMessage":"execute request: %w","messagePattern":"execute request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/datasource/connector/yuque/client.go","lineNumber":78,"sourceCode":"\tfor attempt := 0; attempt <= maxRetries; attempt++ {\n\t\treqURL := c.baseURL + path\n\t\treq, err := http.NewRequestWithContext(ctx, method, reqURL, nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"create request: %w\", err)\n\t\t}\n\t\treq.Header.Set(\"X-Auth-Token\", c.token)\n\t\treq.Header.Set(\"User-Agent\", userAgent)\n\t\treq.Header.Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\n\t\tif attempt == 0 {\n\t\t\tlogger.Infof(ctx, \"[Yuque] %s %s\", method, path)\n\t\t} else {\n\t\t\tlogger.Infof(ctx, \"[Yuque] %s %s (retry %d/%d)\", method, path, attempt, maxRetries)\n\t\t}\n\n\t\tresp, err := c.httpClient.Do(req)\n\t\tif err != nil {\n\t\t\tlastErr = fmt.Errorf(\"execute request: %w\", err)\n\t\t\tif attempt < maxRetries {\n\t\t\t\tif sErr := sleepCtx(ctx, backoff[attempt]); sErr != nil {\n\t\t\t\t\treturn sErr\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn lastErr\n\t\t}\n\n\t\tbody, readErr := io.ReadAll(resp.Body)\n\t\tresp.Body.Close()\n\t\tif readErr != nil {\n\t\t\tlastErr = fmt.Errorf(\"read response body: %w\", readErr)\n\t\t\tif attempt < maxRetries {\n\t\t\t\tif sErr := sleepCtx(ctx, backoff[attempt]); sErr != nil {\n\t\t\t\t\treturn sErr\n\t\t\t\t}\n\t\t\t\tcontinue","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/datasource/connector/yuque/client.go#L60-L96","documentation":"doRequest wraps errors from c.httpClient.Do(req) as \"execute request: %w\". This is the transport layer failing: DNS resolution failure, TCP connect refused/timeout, TLS handshake error, or request cancellation via context. The client retries with backoff up to maxRetries before returning the last error.","triggerScenarios":"Network unreachable from the host running the connector; Yuque API temporarily down or blocked by firewall/proxy; DNS not resolving www.yuque.com; context canceled (client disconnect, shutdown, deadline) mid-request.","commonSituations":"Deploying in an environment without outbound internet or behind a corporate proxy that isn't configured (missing HTTPS_PROXY); DNS failures in containers; transient Yuque outages; request deadlines too short.","solutions":["Test outbound connectivity to the Yuque API from the host: curl -v https://www.yuque.com/api/v2.","Configure proxy environment variables (HTTPS_PROXY) if the network requires one, or fix firewall/egress rules.","Check DNS resolution inside the container/host (nslookup www.yuque.com).","If context canceled, extend the request timeout or investigate why the caller's context was canceled.","Retry later if it's a transient Yuque outage — the client already retries with backoff."],"exampleFix":"// before (no proxy support, blocked network)\nclient := &http.Client{Timeout: 10 * time.Second}\n// after\nproxy := http.ProxyFromEnvironment\ntransport := &http.Transport{Proxy: proxy, TLSHandshakeTimeout: 10 * time.Second}\nclient := &http.Client{Transport: transport, Timeout: 30 * time.Second}","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"www.yuque.com:443\", 5*time.Second)\nif err != nil {\n    return fmt.Errorf(\"Yuque API unreachable: %v\", err)\n}\nconn.Close()","typeGuard":"func isTransportError(err error) bool {\n    var ne net.Error\n    return errors.As(err, &ne) || strings.Contains(err.Error(), \"execute request:\")\n}","tryCatchPattern":"err := client.GetCurrentUser(ctx)\nif err != nil && strings.HasPrefix(err.Error(), \"execute request:\") {\n    if errors.Is(ctx.Err(), context.DeadlineExceeded) {\n        // increase timeout and retry once\n    }\n    return err\n}","preventionTips":["Configure proxy/firewall egress before deploying the connector.","Set generous but bounded request timeouts.","Monitor DNS and outbound connectivity in the deployment environment.","Rely on the built-in backoff retries instead of tight outer retry loops."],"tags":["go","network","http","yuque","retry"],"backgroundTag":"request-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}