{"record":{"id":"aebc3098ba5a965f","repo":"siyuan-note/siyuan","slug":"decode-image-failed","errorCode":null,"errorMessage":"decode image failed: ","messagePattern":"decode image failed: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/openai.go","lineNumber":647,"sourceCode":"\tif strings.Contains(mimeType, \"svg\") || bytes.Contains(bytes.ToLower(data[:min(len(data), 512)]), []byte(\"<svg\")) {\n\t\treturn PreparedImage{}, errors.New(\"SVG images are not accepted by multimodal models\")\n\t}\n\tswitch mimeType {\n\tcase \"image/gif\", \"image/jpeg\", \"image/png\", \"image/webp\":\n\tdefault:\n\t\treturn PreparedImage{}, fmt.Errorf(\"unsupported image type: %s\", mimeType)\n\t}\n\tconfig, _, err := image.DecodeConfig(bytes.NewReader(data))\n\tif err != nil {\n\t\treturn PreparedImage{}, errors.New(\"unsupported or invalid image: \" + err.Error())\n\t}\n\tif config.Width < 1 || config.Height < 1 || maxPixels > 0 && int64(config.Width)*int64(config.Height) > int64(maxPixels) {\n\t\treturn PreparedImage{}, fmt.Errorf(\"image exceeds pixel limit: %d\", maxPixels)\n\t}\n\n\tdecoded, err := imaging.Decode(bytes.NewReader(data), imaging.AutoOrientation(true))\n\tif err != nil {\n\t\treturn PreparedImage{}, errors.New(\"decode image failed: \" + err.Error())\n\t}\n\tbounds := decoded.Bounds()\n\tneedsResize := maxEdge > 0 && (bounds.Dx() > maxEdge || bounds.Dy() > maxEdge)\n\tif !needsResize && bounds.Dx() == config.Width && bounds.Dy() == config.Height && mimeType != \"image/gif\" {\n\t\treturn PreparedImage{\n\t\t\tData:       data,\n\t\t\tMIMEType:   mimeType,\n\t\t\tWidth:      bounds.Dx(),\n\t\t\tHeight:     bounds.Dy(),\n\t\t\tSourceSize: len(data),\n\t\t}, nil\n\t}\n\tif needsResize {\n\t\tdecoded = imaging.Fit(decoded, maxEdge, maxEdge, imaging.Lanczos)\n\t}\n\tbounds = decoded.Bounds()\n\tif mimeType == \"image/png\" || mimeType == \"image/webp\" {\n\t\tvar output bytes.Buffer","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/util/openai.go#L629-L665","documentation":"image.DecodeConfig succeeded but the full imaging.Decode (with AutoOrientation) failed. The header is fine but the pixel body is corrupt, or the format/EXIF case is unsupported by the full decoder.","triggerScenarios":"Header intact but pixel body truncated; corrupt pixel stream; exotic color space / bit depth the full decoder cannot read; bad EXIF that confuses auto-orientation.","commonSituations":"Partially-downloaded JPEG; progressive JPEG cut mid-stream; rare CMYK color profile.","solutions":["Re-download or re-export the asset.","Re-encode through an image tool to strip problem EXIF/color profile.","Re-save as a plain JPEG/PNG."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"img, err := util.PrepareModelImage(data, maxB, maxP, maxE)\nif err != nil {\n    log.Warnf(\"skip unreadable image: %s\", err)\n    continue\n}","preventionTips":["Re-export images that fail full decode","Avoid progressive/truncated JPEGs for vision inputs"],"tags":["ai","multimodal","image","go","corruption"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}