{"record":{"id":"012093bb9906432e","repo":"chenhg5/cc-connect","slug":"unsupported-remote-image-mime-q","errorCode":null,"errorMessage":"unsupported remote image MIME %q","messagePattern":"unsupported remote image MIME %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platform/feishu/feishu.go","lineNumber":6637,"sourceCode":"\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 {\n\t\tresolved, err := net.DefaultResolver.LookupIPAddr(ctx, host)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":6619,"sourceCodeEnd":6655,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L6619-L6655","documentation":"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.","triggerScenarios":"Remote URL returns non-image content (HTML error page with 200, SVG, BMP, TIFF) or an unsupported image format that passes status/size checks.","commonSituations":"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.","solutions":["Ensure the URL points directly at a supported raster image (png/jpeg/gif/webp)","Convert SVG/BMP assets to PNG or JPEG before hosting","Check that a 200 response actually contains image bytes (curl the URL and inspect)","Add a server-side converter/proxy that normalizes formats"],"exampleFix":"// before\nurl := \"https://example.com/logo.svg\"\n// after\nurl := \"https://example.com/logo.png\"","handlingStrategy":"validation","validationCode":"head, err := http.Head(url)\nif err == nil && !strings.HasPrefix(head.Header.Get(\"Content-Type\"), \"image/\") { /* reject early */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Link directly to raster image files (png/jpeg/gif/webp)","Never link SVG or HTML pages as card images","Convert assets before publishing URLs"],"tags":["http","image","mime","validation"],"backgroundTag":"invalid-argument-value","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"}