{"record":{"id":"251cbebb4a390309","repo":"tauri-apps/tauri","slug":"failed-to-parse-plugin-global-api-script-paths","errorCode":null,"errorMessage":"failed to parse plugin global API script paths","messagePattern":"failed to parse plugin global API script paths","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/plugin.rs","lineNumber":72,"sourceCode":"\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}\n","sourceCodeStart":54,"sourceCodeEnd":89,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/plugin.rs#L54-L89","documentation":"After reading the file list, `read_global_api_scripts` parses it with `serde_json::from_str::<Vec<PathBuf>>` and panics with this message on invalid JSON. The saved list is corrupted, truncated, or was written by an incompatible version.","triggerScenarios":"Calling `read_global_api_scripts` when the `GLOBAL_API_SCRIPT_FILE_LIST_PATH` file contains non-JSON or structurally different content — e.g. a truncated write, hand-edited file, or content written by a different tauri-utils version with a different format.","commonSituations":"Interrupted builds leaving a partial file (CI killed mid-write); stale/corrupted incremental-build caches; manually editing files under `target/`; version mismatch between tauri CLI and tauri crates.","solutions":["Run `cargo clean` (or delete the out dir) to force regeneration of the file list","Rebuild without interrupting the build process so the file is written atomically/completely","Do not manually edit files under `target/`; regenerate them instead","Align tauri CLI and tauri crate versions to the same release"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let s = std::fs::read_to_string(out_dir.join(GLOBAL_API_SCRIPT_FILE_LIST_PATH)).unwrap();\nassert!(serde_json::from_str::<Vec<PathBuf>>(&s).is_ok(), \"corrupted global API script list\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit files under target/","Avoid killing builds mid-write; let the build script finish","Keep tauri CLI and crate versions aligned"],"tags":["json","parsing","panic","build-script","tauri"],"backgroundTag":"json-parse-error","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"}