chenhg5/cc-connect · warning

remote image too large: %d bytes

Error message

remote image too large: %d bytes

What it means

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.

Source

Thrown at platform/feishu/feishu.go:6625

		return nil, "", err
	}
	req.Header.Set("User-Agent", "cc-connect-feishu-rich-card-image-resolver/1.0")

	resp, err := client.Do(req)
	if err != nil {
		return nil, "", err
	}
	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)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Serve/resized thumbnail versions of the image below the size limit
  2. Check richCardImageMaxBytes and raise it in config if the deployment allows bigger images
  3. Use an image proxy that resizes/compresses before serving
  4. Ensure URLs point to compressed formats (e.g. webp thumbnails)

Example fix

// before
url := "https://cdn.example.com/original-photo.jpg"
// after
url := "https://cdn.example.com/original-photo.jpg?x-oss-process=image/resize,w_1024"
Defensive patterns

Strategy: validation

Validate before calling

if resp.ContentLength > richCardImageMaxBytes { /* pick thumbnail or abort early */ }

Prevention

When it happens

Trigger: Downloading a card image whose HTTP response has Content-Length exceeding richCardImageMaxBytes.

Common situations: User-configured image URL pointing at a full-size photo/original asset instead of a thumbnail; misconfigured image CDN serving uncompressed images.

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


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/f0413550d368628d. Report an issue: GitHub.