{"record":{"id":"6f4506cc5e7b7884","repo":"chenhg5/cc-connect","slug":"s-cdn-body-exceeds-d-bytes","errorCode":null,"errorMessage":"%s: CDN body exceeds %d bytes","messagePattern":"(.+?): CDN body exceeds (.+?) bytes","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weixin/cdn.go","lineNumber":143,"sourceCode":"func 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 {\n\t\treturn nil, err\n\t}\n\tplain, err := decryptAESECB(enc, key)","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weixin/cdn.go#L125-L161","documentation":"The downloaded CDN body exceeds maxWeixinMediaBytes (detected via LimitReader of max+1), so the media file is larger than the platform is willing to buffer in memory. This is a hard size guard against oversized Weixin media, not a network error.","triggerScenarios":"Thrown at platform/weixin/cdn.go:143 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Skip the oversized attachment and inform the user instead of failing the whole message","If larger files must be supported, raise maxWeixinMediaBytes or stream to disk rather than buffering in memory"],"exampleFix":null,"handlingStrategy":"fallback","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-14T00:17:10.932Z"}