{"record":{"id":"1b5b0cea1841297a","repo":"tauri-apps/tauri","slug":"failed-to-parse-icon","errorCode":null,"errorMessage":"failed to parse icon {}: {}","messagePattern":"failed to parse icon (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-codegen/src/image.rs","lineNumber":55,"sourceCode":"    }\n  }\n\n  /// Cache the icon without any manipulation.\n  pub fn new_raw(root: &TokenStream, icon: &Path) -> EmbeddedAssetsResult<Self> {\n    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","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-codegen/src/image.rs#L37-L73","documentation":"Compile-time panic in tauri-codegen's icon handling (tauri::image module used by generate_context!). new_ico reads the .ico file into memory and hands it to ico::IconDir::read; if the bytes are not a parseable ICO container (bad header/magic, truncated file), it panics with the icon path and the parse error.","triggerScenarios":"A file listed in bundle > icon that has an .ico extension but is not actually an ICO: a renamed PNG/JPEG, an HTML error page saved as icon.ico, a git-LFS pointer file, or a truncated download.","commonSituations":"Downloading icons from the web and trusting the extension; LFS not pulled on CI; manual conversion that produced an empty/corrupt file.","solutions":["Regenerate the full icon set from a single square PNG source: `npx tauri icon path/to/icon.png`","Verify the real format: `file icons/icon.ico` should report 'MS Windows icon resource'","Replace the corrupt file with a valid ICO produced by a proper converter (ImageMagick/GIMP)"],"exampleFix":"# before\nfile src-tauri/icons/icon.ico   # 'PNG image data' -> panic: failed to parse icon\n\n# after\nnpx tauri icon ./app-icon.png   # regenerates valid icons incl. icon.ico\nfile src-tauri/icons/icon.ico   # 'MS Windows icon resource'","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nfor ico in src-tauri/icons/*.ico; do\n  file \"$ico\" | grep -q 'MS Windows icon' || { echo \"not a valid ICO: $ico\"; exit 1; }\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate the whole icon set with `npx tauri icon <png>` instead of sourcing icons manually","Verify icon files with `file`/`magick identify` in CI","Pull git-LFS objects before building if icons are stored in LFS"],"tags":["icons","ico","tauri-codegen","codegen","image","build"],"backgroundTag":"invalid-image-format","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}