{"record":{"id":"9779fadb2d8bdc21","repo":"chenhg5/cc-connect","slug":"http-get-w","errorCode":null,"errorMessage":"http get: %w","messagePattern":"http get: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/dingtalk/dingtalk.go","lineNumber":652,"sourceCode":"\t\t\tData:     fileBytes,\n\t\t\tFileName: fileName,\n\t\t}},\n\t}\n\n\tp.handler(p, msg)\n}\n\nfunc (p *Platform) downloadAudio(downloadCode string) ([]byte, string, error) {\n\t// Get download URL\n\tdownloadURL, err := p.getDownloadURL(downloadCode)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"get download URL: %w\", err)\n\t}\n\n\t// Download audio file\n\tresp, err := p.httpClient.Get(downloadURL)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"http get: %w\", err)\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, \"\", fmt.Errorf(\"download returned status %d\", resp.StatusCode)\n\t}\n\n\tdata, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"read response: %w\", err)\n\t}\n\n\t// Determine MIME type from Content-Type header\n\tmimeType := resp.Header.Get(\"Content-Type\")\n\tif mimeType == \"\" {\n\t\tmimeType = \"audio/amr\" // Default to AMR if not specified\n\t}\n","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/dingtalk/dingtalk.go#L634-L670","documentation":"downloadAudio failed at the second stage: the plain HTTP GET of the resolved downloadURL failed. This is a transport-level error (connection refused, DNS failure, TLS problem, timeout) reported via the injected httpClient.","triggerScenarios":"p.httpClient.Get(downloadURL) returned a non-nil error while downloading the audio file bytes from the URL obtained from DingTalk.","commonSituations":"Host has no outbound internet access or a broken proxy; the short-lived download URL already expired (some CDNs then drop connections); DNS misconfiguration; TLS certificate issues in restricted environments.","solutions":["Check outbound network connectivity and proxy settings on the host.","Re-download promptly — the DingTalk download URL is short-lived; if delayed, fetch a fresh URL via getDownloadURL.","Confirm the download URL scheme is https and not corrupted by the webhook payload.","If cause is a timeout, increase the httpClient timeout or retry once."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-check connectivity at startup:\nresp, err := http.Get(\"https://download.dingtalk.com\") // or any DingTalk host\nif err != nil { log.Fatal(\"no outbound access to DingTalk CDN: \", err) }\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.Is(err, context.DeadlineExceeded) { /* timeout: increase or back off */ }\n    log.Warn(\"audio download failed (network)\", \"err\", err)\n    return retryOnce()\n}","preventionTips":["Download immediately after receiving the message — URLs are short-lived","Configure a sane httpClient timeout","Ensure outbound HTTPS is allowed through proxies/firewalls"],"tags":["dingtalk","audio","network","http"],"backgroundTag":"http-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}