{"record":{"id":"05726f4c09634c40","repo":"tauri-apps/tauri","slug":"failed-to-decode-icon","errorCode":null,"errorMessage":"failed to decode icon {}: {}","messagePattern":"failed to decode icon (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-codegen/src/image.rs","lineNumber":60,"sourceCode":"    let buf = Self::open(icon);\n    Cached::try_from(buf).map(|cache| Self {\n      cache,\n      root: root.clone(),\n      format: IconFormat::Raw,\n    })\n  }\n\n  /// Cache an ICO icon as RGBA data, see [`ImageFormat::Image`].\n  pub fn new_ico(root: &TokenStream, icon: &Path) -> EmbeddedAssetsResult<Self> {\n    let buf = Self::open(icon);\n\n    let icon_dir = ico::IconDir::read(Cursor::new(&buf))\n      .unwrap_or_else(|e| panic!(\"failed to parse icon {}: {}\", icon.display(), e));\n\n    let entry = &icon_dir.entries()[0];\n    let rgba = entry\n      .decode()\n      .unwrap_or_else(|e| panic!(\"failed to decode icon {}: {}\", icon.display(), e))\n      .rgba_data()\n      .to_vec();\n\n    Cached::try_from(rgba).map(|cache| Self {\n      cache,\n      root: root.clone(),\n      format: IconFormat::Image {\n        width: entry.width(),\n        height: entry.height(),\n      },\n    })\n  }\n\n  /// Cache a PNG icon as RGBA data, see [`ImageFormat::Image`].\n  pub fn new_png(root: &TokenStream, icon: &Path) -> EmbeddedAssetsResult<Self> {\n    let buf = Self::open(icon);\n    let decoder = png::Decoder::new(Cursor::new(&buf));\n    let mut reader = decoder","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-codegen/src/image.rs#L42-L78","documentation":"After the ICO container parses, new_ico decodes its first entry's image into RGBA. If entry.decode() fails — unsupported bit depth, compression variant, or corrupt image data inside a structurally valid ICO — this panic fires with the icon path and decode error.","triggerScenarios":"An .ico whose first entry uses an unsupported encoding (e.g. exotic compression or PNG-compressed entry the `ico` crate cannot decode); truncated image data inside the ICO.","commonSituations":"Icons exported by niche tools with unusual internal formats; ICOs containing PNG-compressed frames; corrupted assets after a bad merge or LFS checkout.","solutions":["Re-encode the .ico with standard BMP-embedded 32-bit RGBA frames (e.g. via ImageMagick or icoconvert)","Remove or reorder entries so the first entry is a standard size like 32x32","Open the icon in an image editor and re-export it","Fall back to a plain PNG icon via the PNG code path"],"exampleFix":"// before\nico made by exotic tool, png-compressed frames\n// after\nmagick icon.png -define icon:auto-resize=32,16 -compress zip icon.ico","handlingStrategy":"validation","validationCode":"from PIL import Image\nim = Image.open('icon.ico')\nim.load()  # raises if frames are corrupt/undecodable\nprint(im.size, im.mode)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-export icons from a mainstream editor after any external source","Prefer standard 32-bit RGBA frames inside the ICO","Validate icons with Pillow/ImageMagick identify in CI","Avoid exotic third-party ICO generators"],"tags":["icon","ico","decode","codegen"],"backgroundTag":"invalid-argument-value","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}