{"record":{"id":"4ca72ac63bef6891","repo":"tauri-apps/tauri","slug":"failed-to-convert-bundle-filename-to-string","errorCode":null,"errorMessage":"failed to convert bundle filename to string","messagePattern":"failed to convert bundle filename to string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-macos-sign/src/lib.rs","lineNumber":258,"sourceCode":"        String::from_utf8_lossy(&output.stdout)\n      )))\n    } else {\n      Err(Error::Notarize(log_message))\n    }\n  } else {\n    Err(Error::ParseNotarytoolOutput {\n      output: output_str.into_owned(),\n    })\n  }\n}\n\nfn staple_app(mut app_bundle_path: PathBuf) -> Result<()> {\n  let app_bundle_path_clone = app_bundle_path.clone();\n  let filename = app_bundle_path_clone\n    .file_name()\n    .expect(\"failed to get bundle filename\")\n    .to_str()\n    .expect(\"failed to convert bundle filename to string\");\n\n  app_bundle_path.pop();\n\n  Command::new(\"xcrun\")\n    .args(vec![\"stapler\", \"staple\", \"-v\", filename])\n    .current_dir(app_bundle_path)\n    .output()\n    .map_err(|error| Error::CommandFailed {\n      command: \"xcrun stapler staple\".to_string(),\n      error,\n    })?;\n\n  Ok(())\n}\n\npub trait NotarytoolCmdExt {\n  fn notarytool_args(\n    &mut self,","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-macos-sign/src/lib.rs#L240-L276","documentation":"Panic in tauri-macos-sign's staple step: the bundle filename from file_name() is converted with .to_str().expect(\"failed to convert bundle filename to string\"), which fails when the filename contains bytes that are not valid UTF-8. `xcrun stapler staple` needs a string argument, so a non-UTF-8 .app name aborts stapling.","triggerScenarios":"Stapling a bundle whose filename (not the whole path) includes non-UTF-8 bytes — artifact names mangled by archive tools or created on systems with legacy locale encodings.","commonSituations":"Extracted archives preserving invalid byte sequences; filenames pasted from rich text introducing invisible invalid bytes.","solutions":["Rename the .app to pure ASCII/UTF-8 before stapling","Regenerate the artifact from a clean pipeline step","Validate in your wrapper: path.file_name().and_then(|n| n.to_str()).is_some() before invoking the flow"],"exampleFix":"# before\nstaple \"My App\\xa0.app\"  → panic: failed to convert bundle filename to string\n\n# after\nmv \"$(printf 'My App\\xa0.app')\" \"MyApp.app\" && staple \"MyApp.app\"","handlingStrategy":"validation","validationCode":"let name_ok = app_bundle_path\n    .file_name()\n    .and_then(|n| n.to_str())\n    .is_some_and(|n| n.ends_with(\".app\"));\nassert!(name_ok, \"bundle filename must be UTF-8 and end in .app\");","typeGuard":"fn utf8_file_name(p: &std::path::Path) -> Option<&str> { p.file_name().and_then(|n| n.to_str()) }","tryCatchPattern":null,"preventionTips":["Use ASCII bundle names","Sanity-check filenames with `file` or `iconv` when artifacts come from third-party machines"],"tags":["macos","stapling","utf8","path"],"backgroundTag":"non-utf8-path","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}