{"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/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-codegen/src/image.rs#L37-L73","documentation":"EmbeddedImage::new_ico reads an .ico file and parses it with the `ico` crate during macro expansion. If ico::IconDir::read fails — the file is not a valid ICO container or is truncated/corrupt — the macro panics with this message, naming the icon path and the underlying parse error.","triggerScenarios":"Passing an `icon` path whose bytes are not a valid ICO (e.g. a PNG renamed to .ico with a header the parser rejects, or a truncated download) into tauri::icon! / EmbeddedAssets icon handling.","commonSituations":"Renaming a PNG to .ico instead of converting; icons corrupted by git LFS smudge failure; partially downloaded icon files; icons generated by tools producing unsupported ICO variants.","solutions":["Regenerate the .ico with a proper converter (e.g. `ImageMagick: magick icon.png -define icon:auto-resize=32,16 icon.ico`)","Verify the file starts with the ICO magic bytes 00 00 01 00","Re-download or restore the icon from version control","Use a PNG icon with ImageFormat::Png instead of ICO"],"exampleFix":"// before\ncp icon.png icon.ico  // invalid: renamed PNG\n// after\nmagick icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico","handlingStrategy":"validation","validationCode":"with open('icon.ico','rb') as f:\n    if f.read(4) != b'\\x00\\x00\\x01\\x00':\n        raise SystemExit('not a valid ICO file')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate ICOs with a real converter, never by renaming PNGs","Check icon files into git without LFS smudge issues, or verify checksums","Keep icons as standard multi-size 32-bit BMP-frame ICOs","Add a pre-commit hook validating icon magic bytes"],"tags":["icon","ico","codegen","parse"],"backgroundTag":"invalid-argument-format","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"}