chenhg5/cc-connect · warning

unsupported remote image MIME %q

Error message

unsupported remote image MIME %q

What it means

The downloaded image passed the size checks but its content type, sniffed with http.DetectContentType, is not in the supported set (typically png/jpeg/gif/webp). Feishu rich-card image keys only accept certain MIME types.

Source

Thrown at platform/feishu/feishu.go:6637

	}()

	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 {
		resolved, err := net.DefaultResolver.LookupIPAddr(ctx, host)
		if err != nil {
			return nil, err
		}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Ensure the URL points directly at a supported raster image (png/jpeg/gif/webp)
  2. Convert SVG/BMP assets to PNG or JPEG before hosting
  3. Check that a 200 response actually contains image bytes (curl the URL and inspect)
  4. Add a server-side converter/proxy that normalizes formats

Example fix

// before
url := "https://example.com/logo.svg"
// after
url := "https://example.com/logo.png"
Defensive patterns

Strategy: validation

Validate before calling

head, err := http.Head(url)
if err == nil && !strings.HasPrefix(head.Header.Get("Content-Type"), "image/") { /* reject early */ }

Prevention

When it happens

Trigger: Remote URL returns non-image content (HTML error page with 200, SVG, BMP, TIFF) or an unsupported image format that passes status/size checks.

Common situations: URL pointing to an HTML page instead of an image file (e.g. a gallery link); SVG logos; images served with no extension but actually unsupported formats; server returning 200 with an error page.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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