{"record":{"id":"dfd7f5b187971c46","repo":"chenhg5/cc-connect","slug":"do-request-w","errorCode":null,"errorMessage":"do request: %w","messagePattern":"do request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/dingtalk/card.go","lineNumber":131,"sourceCode":"\n\treqCtx, cancel := context.WithTimeout(ctx, 30*time.Second)\n\tdefer cancel()\n\n\treq, err := http.NewRequestWithContext(reqCtx, http.MethodPost,\n\t\t\"https://api.dingtalk.com/v1.0/card/instances/createAndDeliver\",\n\t\tbytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create request: %w\", err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"x-acs-dingtalk-access-token\", token)\n\n\tslog.Debug(\"dingtalk: creating AI card\", \"outTrackId\", outTrackId, \"isGroup\", isGroup)\n\n\tresp, err := p.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"do request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\n\tslog.Debug(\"dingtalk: createAndDeliver response\",\n\t\t\"status\", resp.StatusCode,\n\t\t\"body\", string(respBody))\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tslog.Error(\"dingtalk: create AI card failed\",\n\t\t\t\"status\", resp.StatusCode,\n\t\t\t\"body\", string(respBody))\n\t\t// Check if we should trigger degrade\n\t\tif resp.StatusCode == 403 || resp.StatusCode == 429 || resp.StatusCode >= 500 {\n\t\t\tp.activateCardDegrade(fmt.Sprintf(\"card.create:%d\", resp.StatusCode))\n\t\t}\n\t\treturn nil, fmt.Errorf(\"create AI card: status=%d, body=%s\", resp.StatusCode, string(respBody))","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/dingtalk/card.go#L113-L149","documentation":"This error wraps a network-level failure from httpClient.Do when POSTing the createAndDeliver request (platform/dingtalk/card.go:131, createAICard). It means the request never got an HTTP response: DNS failure, connection refused/reset, TLS error, or the 30-second context timeout (reqCtx) expired. No DingTalk API call happened, so no rate limit or auth logic applies.","triggerScenarios":" httpClient.Do returns error during CreateStreamingCard: DNS resolution failure for api.dingtalk.com, TCP connect refused/blocked, TLS handshake failure, or the 30s reqCtx deadline exceeded before a response.","commonSituations":"No outbound internet access or firewalled egress on the host; api.dingtalk.com blocked by corporate proxy/firewall; transient network flaps; slow network pushing the request past the 30s timeout; IPv6 misrouting.","solutions":["Check host egress: curl -v https://api.dingtalk.com/v1.0/card/instances/createAndDeliver from the same machine","Inspect the wrapped error: *url.Error with \"context deadline exceeded\" means the 30s timeout fired; \"connection refused\"/\"no such host\" means network/DNS","Configure the platform's httpClient proxy if behind a corporate proxy (http.Transport Proxy setting)","Retry the card creation — flush/Finalize paths tolerate transient stream failures, and card degrade mode activates on repeated failures","Check logs for activateCardDegrade; if degraded to plain text messages, fix connectivity first"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight connectivity check\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\nreq, _ := http.NewRequestWithContext(ctx, \"GET\", \"https://api.dingtalk.com\", nil)\nif _, err := http.DefaultClient.Do(req); err != nil {\n\tlog.Printf(\"dingtalk unreachable: %v\", err)\n}\ncancel()","typeGuard":null,"tryCatchPattern":"card, err := p.CreateStreamingCard(ctx, msg)\nif err != nil {\n\tvar ne *net.OpError\n\tvar te *url.Error\n\tif errors.As(err, &ne) || (errors.As(err, &te) && te.Timeout()) {\n\t\t// transient network issue: retry with backoff or fall back to plain text\n\t}\n}","preventionTips":["Whitelist egress to api.dingtalk.com:443 on firewalls/proxies","Configure an HTTP(S) proxy on the platform's httpClient if the host requires one","Monitor DNS health on the deployment host","Keep the 30s timeout in mind for slow links; avoid oversubscribing bandwidth during streaming"],"tags":["network","http","timeout","dingtalk"],"backgroundTag":"network-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}