{"record":{"id":"d1f29995b5d793e3","repo":"chenhg5/cc-connect","slug":"remote-image-exceeds-d-bytes","errorCode":null,"errorMessage":"remote image exceeds %d bytes","messagePattern":"remote image exceeds (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platform/feishu/feishu.go","lineNumber":6633,"sourceCode":"\tdefer func() {\n\t\tif err := resp.Body.Close(); err != nil {\n\t\t\tslog.Debug(\"feishu: close rich card image response body\", \"error\", err)\n\t\t}\n\t}()\n\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\treturn nil, \"\", fmt.Errorf(\"remote image HTTP status %d\", resp.StatusCode)\n\t}\n\tif resp.ContentLength > richCardImageMaxBytes {\n\t\treturn nil, \"\", fmt.Errorf(\"remote image too large: %d bytes\", resp.ContentLength)\n\t}\n\n\tdata, err := io.ReadAll(io.LimitReader(resp.Body, richCardImageMaxBytes+1))\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tif len(data) > richCardImageMaxBytes {\n\t\treturn nil, \"\", fmt.Errorf(\"remote image exceeds %d bytes\", richCardImageMaxBytes)\n\t}\n\tmimeType := http.DetectContentType(data)\n\tif !isSupportedRichCardImageMIME(mimeType) {\n\t\treturn nil, \"\", fmt.Errorf(\"unsupported remote image MIME %q\", mimeType)\n\t}\n\treturn data, mimeType, nil\n}\n\nfunc dialPublicRichCardImageContext(ctx context.Context, network, address string) (net.Conn, error) {\n\thost, port, err := net.SplitHostPort(address)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar ips []net.IP\n\tif parsed := net.ParseIP(host); parsed != nil {\n\t\tips = []net.IP{parsed}\n\t} else {","sourceCodeStart":6615,"sourceCodeEnd":6651,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L6615-L6651","documentation":"After streaming the body through io.LimitReader(richCardImageMaxBytes+1), the actual byte count exceeded richCardImageMaxBytes. This catches servers that send no/wrong Content-Length (chunked encoding) where the 1245 check cannot fire.","triggerScenarios":"Downloading a card image where the server omits Content-Length (chunked transfer) or lies about it, and the body turns out larger than the limit.","commonSituations":"Chunked responses from CDNs; streaming endpoints; servers with incorrect Content-Length headers.","solutions":["Reduce image size server-side or switch to a thumbnail URL","Raise richCardImageMaxBytes if appropriate for the deployment","Point the card to a static file host that sets accurate Content-Length","Proxy and re-encode the image through a resizing service"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// after reading: if len(data) > limit { abort } — pre-check via HEAD request Content-Length when available","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer hosts that set accurate Content-Length","Re-encode oversized images through a resizing proxy"],"tags":["http","image","size-limit","feishu"],"backgroundTag":"file-size-limit-exceeded","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"}