{"record":{"id":"f0413550d368628d","repo":"chenhg5/cc-connect","slug":"remote-image-too-large-d-bytes","errorCode":null,"errorMessage":"remote image too large: %d bytes","messagePattern":"remote image too large: (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platform/feishu/feishu.go","lineNumber":6625,"sourceCode":"\t\treturn nil, \"\", err\n\t}\n\treq.Header.Set(\"User-Agent\", \"cc-connect-feishu-rich-card-image-resolver/1.0\")\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\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)","sourceCodeStart":6607,"sourceCodeEnd":6643,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L6607-L6643","documentation":"Rich-card remote image resolver: the fetched image's Content-Length exceeds richCardImageMaxBytes, so it is rejected before buffering — a memory guard against huge remote images referenced in markdown cards.","triggerScenarios":"Downloading a card image whose HTTP response has Content-Length exceeding richCardImageMaxBytes.","commonSituations":"User-configured image URL pointing at a full-size photo/original asset instead of a thumbnail; misconfigured image CDN serving uncompressed images.","solutions":["Serve/resized thumbnail versions of the image below the size limit","Check richCardImageMaxBytes and raise it in config if the deployment allows bigger images","Use an image proxy that resizes/compresses before serving","Ensure URLs point to compressed formats (e.g. webp thumbnails)"],"exampleFix":"// before\nurl := \"https://cdn.example.com/original-photo.jpg\"\n// after\nurl := \"https://cdn.example.com/original-photo.jpg?x-oss-process=image/resize,w_1024\"","handlingStrategy":"validation","validationCode":"if resp.ContentLength > richCardImageMaxBytes { /* pick thumbnail or abort early */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Link to thumbnails, not originals","Compress images at upload time","Know the configured richCardImageMaxBytes"],"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-14T05:17:10.506Z"}