{"record":{"id":"d47c02b9943c0cb2","repo":"tauri-apps/tauri","slug":"failed-to-read-icon","errorCode":null,"errorMessage":"failed to read icon {}: {}","messagePattern":"failed to read icon (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-codegen/src/image.rs","lineNumber":80,"sourceCode":"      .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\n      .read_info()\n      .unwrap_or_else(|e| panic!(\"failed to read icon {}: {}\", icon.display(), e));\n\n    if reader.output_color_type().0 != png::ColorType::Rgba {\n      panic!(\"icon {} is not RGBA\", icon.display());\n    }\n\n    let mut rgba = Vec::with_capacity(reader.output_buffer_size().unwrap());\n    while let Ok(Some(row)) = reader.next_row() {\n      rgba.extend(row.data());\n    }\n\n    Cached::try_from(rgba).map(|cache| Self {\n      cache,\n      root: root.clone(),\n      format: IconFormat::Image {\n        width: reader.info().width,\n        height: reader.info().height,\n      },\n    })","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-codegen/src/image.rs#L62-L98","documentation":"EmbeddedImage::new_png decodes a PNG icon during macro expansion. png::Decoder::read_info() failing (invalid PNG signature, corrupt chunks, unsupported format) triggers this panic with the icon path and decoder error, aborting the build.","triggerScenarios":"A .png passed to the icon/embedded-image path that is not a valid PNG (wrong magic bytes, truncated file, interlaced variant the decoder rejects).","commonSituations":"Renamed JPEG/GIF/WebP files with a .png extension; truncated PNGs from failed downloads or interrupted transfers; corrupt assets after a bad git checkout.","solutions":["Verify the file is a real PNG (`file icon.png` should report PNG image data)","Re-export or re-encode the image as PNG (e.g. `magick input.webp output.png`)","Re-download or restore the icon from version control","Open the PNG in an editor and re-save it"],"exampleFix":"// before\ncp photo.jpg icon.png\n// after\nmagick photo.jpg -resize 32x32 icon.png","handlingStrategy":"validation","validationCode":"import imghdr, sys\nif imghdr.what('icon.png') != 'png':\n    sys.exit('icon.png is not a real PNG')\n# or: from PIL import Image; Image.open('icon.png').verify()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never rename other formats to .png; always transcode","Verify downloads with checksums","Run `magick identify` on icons in CI","Re-save suspect icons in an editor before committing"],"tags":["icon","png","codegen","decode"],"backgroundTag":"json-decode-failed","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"}