chenhg5/cc-connect · warning
remote image exceeds %d bytes
Error message
remote image exceeds %d bytes
What it means
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.
Source
Thrown at platform/feishu/feishu.go:6633
defer func() {
if err := resp.Body.Close(); err != nil {
slog.Debug("feishu: close rich card image response body", "error", err)
}
}()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return nil, "", fmt.Errorf("remote image HTTP status %d", resp.StatusCode)
}
if resp.ContentLength > richCardImageMaxBytes {
return nil, "", fmt.Errorf("remote image too large: %d bytes", resp.ContentLength)
}
data, err := io.ReadAll(io.LimitReader(resp.Body, richCardImageMaxBytes+1))
if err != nil {
return nil, "", err
}
if len(data) > richCardImageMaxBytes {
return nil, "", fmt.Errorf("remote image exceeds %d bytes", richCardImageMaxBytes)
}
mimeType := http.DetectContentType(data)
if !isSupportedRichCardImageMIME(mimeType) {
return nil, "", fmt.Errorf("unsupported remote image MIME %q", mimeType)
}
return data, mimeType, nil
}
func dialPublicRichCardImageContext(ctx context.Context, network, address string) (net.Conn, error) {
host, port, err := net.SplitHostPort(address)
if err != nil {
return nil, err
}
var ips []net.IP
if parsed := net.ParseIP(host); parsed != nil {
ips = []net.IP{parsed}
} else {View on GitHub (pinned to 4000b2338a)
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
Defensive patterns
Strategy: validation
Validate before calling
// after reading: if len(data) > limit { abort } — pre-check via HEAD request Content-Length when available Prevention
- Prefer hosts that set accurate Content-Length
- Re-encode oversized images through a resizing proxy
When it happens
Trigger: 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.
Common situations: Chunked responses from CDNs; streaming endpoints; servers with incorrect Content-Length headers.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- remote image too large: %d bytes
- too many redirects
- remote image HTTP status %d
- invalid remote image URL
- init failed: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/d1f29995b5d793e3.
Report an issue: GitHub.