{"record":{"id":"3625f55b02fec92a","repo":"chenhg5/cc-connect","slug":"s-read-w","errorCode":null,"errorMessage":"%s: read: %w","messagePattern":"(.+?): read: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weixin/cdn.go","lineNumber":140,"sourceCode":"\t\turl.QueryEscape(filekey))\n}\n\nfunc fetchCdnBytes(ctx context.Context, client *http.Client, fullURL, label string) ([]byte, error) {\n\tif client == nil {\n\t\tclient = http.DefaultClient\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, fullURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: new request: %w\", label, err)\n\t}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: get: %w\", label, err)\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, maxWeixinMediaBytes+1))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: read: %w\", label, err)\n\t}\n\tif len(body) > maxWeixinMediaBytes {\n\t\treturn nil, fmt.Errorf(\"%s: CDN body exceeds %d bytes\", label, maxWeixinMediaBytes)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"%s: CDN http %d: %s\", label, resp.StatusCode, truncateForLog(body, 256))\n\t}\n\treturn body, nil\n}\n\nfunc downloadAndDecryptCDN(ctx context.Context, client *http.Client, cdnBase, encParam, aesKeyBase64, label string) ([]byte, error) {\n\tkey, err := parseAesKey(aesKeyBase64, label)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tu := buildCdnDownloadURL(encParam, cdnBase)\n\tenc, err := fetchCdnBytes(ctx, client, u, label)\n\tif err != nil {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weixin/cdn.go#L122-L158","documentation":"Reading the CDN response body in fetchCdnBytes failed mid-stream (io.ReadAll over a LimitReader) — the connection was reset or timed out after headers were received, so the Weixin media download completed only partially.","triggerScenarios":"Thrown at platform/weixin/cdn.go:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the CDN download; partial reads are typically transient network resets","Set/enforce client and read timeouts so a stalled body does not hang the media pipeline","Discard partial data on failure — never forward truncated ciphertext to decryption"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}