{"record":{"id":"b70d7c5eb057b97f","repo":"tauri-apps/tauri","slug":"failed-to-read-plugin-global-api-script-paths","errorCode":null,"errorMessage":"failed to read plugin global API script paths","messagePattern":"failed to read plugin global API script paths","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/plugin.rs","lineNumber":70,"sourceCode":"      scripts.insert(0, tauri_global_scripts);\n    }\n\n    fs::write(\n      out_dir.join(GLOBAL_API_SCRIPT_FILE_LIST_PATH),\n      serde_json::to_string(&scripts).expect(\"failed to serialize global API script paths\"),\n    )\n    .expect(\"failed to write global API script\");\n  }\n\n  /// Read global api scripts from [`GLOBAL_API_SCRIPT_FILE_LIST_PATH`]\n  pub fn read_global_api_scripts(out_dir: &Path) -> Option<Vec<String>> {\n    let global_scripts_path = out_dir.join(GLOBAL_API_SCRIPT_FILE_LIST_PATH);\n    if !global_scripts_path.exists() {\n      return None;\n    }\n\n    let global_scripts_str = fs::read_to_string(global_scripts_path)\n      .expect(\"failed to read plugin global API script paths\");\n    let global_scripts = serde_json::from_str::<Vec<PathBuf>>(&global_scripts_str)\n      .expect(\"failed to parse plugin global API script paths\");\n\n    Some(\n      global_scripts\n        .into_iter()\n        .map(|p| {\n          fs::read_to_string(&p).unwrap_or_else(|e| {\n            panic!(\n              \"failed to read plugin global API script {}: {e}\",\n              p.display()\n            )\n          })\n        })\n        .collect(),\n    )\n  }\n}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/plugin.rs#L52-L88","documentation":"`read_global_api_scripts` reads the previously saved file list from `GLOBAL_API_SCRIPT_FILE_LIST_PATH` with `fs::read_to_string` and panics with this message if the read fails. Note the existence check only guards a missing file; I/O errors (permissions, races where the file vanishes between `exists()` and read) trigger the panic.","triggerScenarios":"Calling `read_global_api_scripts` with an `out_dir` pointing at a location where the file list exists but is unreadable: wrong permissions, the path being a directory, or a TOCTOU race where the file is deleted after the `exists()` check.","commonSituations":"Mixing build outputs from different workspaces; CI cache restoring a partially written out dir; permission-restricted build directories; concurrent builds racing on the same OUT_DIR.","solutions":["Verify the file list is readable and a regular file in the given `out_dir` before calling","Do a clean rebuild (`cargo clean`) to regenerate a valid out dir","Fix permissions on the build output directory","Avoid concurrent builds sharing the same OUT_DIR"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let p = out_dir.join(GLOBAL_API_SCRIPT_FILE_LIST_PATH);\nif !p.is_file() {\n  // treat as missing instead of reading\n  return None;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer checking `is_file()` over `exists()` to catch directories","Avoid concurrent builds sharing one OUT_DIR","Clean-rebuild when CI caches may hold partial outputs"],"tags":["file-read","filesystem","panic","build-script","tauri"],"backgroundTag":"file-read-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"}