{"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/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-codegen/src/image.rs#L42-L78","documentation":"Compile-time panic in tauri-codegen's new_ico. The ICO container parsed successfully (IconDir::read) but decoding its first entry via entry.decode() failed, i.e. the embedded bitmap/PNG payload inside the ICO is invalid or unsupported, so RGBA data cannot be extracted for embedding.","triggerScenarios":"An ICO whose directory header is fine but whose entry payload is corrupt: malformed BMP header, zero width/height, unsupported bit depth, or a truncated image stream produced by a buggy icon converter.","commonSituations":"ICOs exported by niche online converters; files damaged in transfer or by partial git checkouts; icon variants with exotic compression the ico crate cannot decode.","solutions":["Regenerate icons from source with `npx tauri icon app-icon.png`, which emits well-formed multi-size ICO/PNGs","Re-export the ICO from a mainstream tool (GIMP, ImageMagick) including standard sizes (16/32/48/256)","Validate the file decodes before building: `magick identify icon.ico` or `pngcheck` on the payload"],"exampleFix":"# before\n# icon.ico parses but entry payload is corrupt -> panic: failed to decode icon\n\n# after\nnpx tauri icon ./app-icon.png   # regenerates decodable icon.ico\ncargo build                    # codegen succeeds","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# prove every .ico decodes end-to-end before the Rust build\nfor ico in src-tauri/icons/*.ico; do magick identify \"$ico\" >/dev/null || { echo \"undecodable icon: $ico\"; exit 1; }; done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate icons with `tauri icon` whenever the source image changes","Re-export ICOs only from mainstream tools (GIMP/ImageMagick) with standard sizes","Treat any icon that was hand-converted once as suspect: re-derive it from the source PNG"],"tags":["icons","ico","image-decode","tauri-codegen","codegen","build"],"backgroundTag":"image-decode-failed","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}