{"record":{"id":"7e389711e947489a","repo":"tw93/Pake","slug":"failed-to-parse-tauri-config","errorCode":null,"errorMessage":"Failed to parse tauri config","messagePattern":"Failed to parse tauri config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-tauri/src/util.rs","lineNumber":18,"sourceCode":"use crate::app::config::PakeConfig;\nuse crate::app::window::MultiWindowState;\nuse std::env;\nuse std::path::{Path, PathBuf};\nuse tauri::{AppHandle, Config, Manager, WebviewWindow};\n\npub fn get_pake_config() -> (PakeConfig, Config) {\n    #[cfg(feature = \"cli-build\")]\n    let pake_config: PakeConfig = serde_json::from_str(include_str!(\"../.pake/pake.json\"))\n        .expect(\"Failed to parse pake config\");\n\n    #[cfg(not(feature = \"cli-build\"))]\n    let pake_config: PakeConfig =\n        serde_json::from_str(include_str!(\"../pake.json\")).expect(\"Failed to parse pake config\");\n\n    #[cfg(feature = \"cli-build\")]\n    let tauri_config: Config = serde_json::from_str(include_str!(\"../.pake/tauri.conf.json\"))\n        .expect(\"Failed to parse tauri config\");\n\n    #[cfg(not(feature = \"cli-build\"))]\n    let tauri_config: Config = serde_json::from_str(include_str!(\"../tauri.conf.json\"))\n        .expect(\"Failed to parse tauri config\");\n\n    (pake_config, tauri_config)\n}\n\npub fn get_data_dir(app: &AppHandle, package_name: String) -> std::io::Result<PathBuf> {\n    let data_dir = app\n        .path()\n        .config_dir()\n        .map_err(|err| {\n            std::io::Error::new(\n                std::io::ErrorKind::NotFound,\n                format!(\"Failed to resolve config dir: {err}\"),\n            )\n        })?","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/tw93/Pake/blob/c8fe8a3f1a115428e3555c06b3de9b7458aa0d54/src-tauri/src/util.rs#L1-L36","documentation":"get_pake_config also deserializes the embedded tauri.conf.json into tauri::Config with serde_json, panicking with this expect message if it fails. Because the file is compiled in, an invalid tauri.conf.json breaks the app before any window is created.","triggerScenarios":"tauri.conf.json (or .pake/tauri.conf.json under cli-build) contains JSON syntax errors or values violating Tauri v2's Config schema (e.g. bad bundle identifier, wrong types in windows options).","commonSituations":"Hand edits for custom icons/identifiers that break the schema; a Tauri major-version upgrade changing required fields; merge conflicts resolved incorrectly in tauri.conf.json.","solutions":["Validate tauri.conf.json against the Tauri v2 config schema (tauri CLI: `cargo tauri dev` reports the schema error).","Fix JSON syntax or field types (check identifier, bundle, and windows sections).","If the file was mutated by a build, restore it from git and re-run the pake CLI."],"exampleFix":"// before (tauri.conf.json)\n{ \"identifier\": \"\" }\n// after\n{ \"identifier\": \"com.example.pakeapp\" }","handlingStrategy":"validation","validationCode":"const conf = JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json'));\nif (typeof conf.identifier !== 'string' || conf.identifier.length === 0) throw new Error('tauri.conf.json identifier missing');","typeGuard":"const looksLikeTauriConfig = (c) => typeof c === 'object' && c !== null && typeof c.identifier === 'string';","tryCatchPattern":"// dev-time guard\ntry { JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json', 'utf8')); } catch (e) { console.error('tauri.conf.json invalid:', e.message); process.exit(1); }","preventionTips":["Let the Tauri CLI manage tauri.conf.json edits; run `cargo tauri dev` to see schema errors immediately","After Tauri version upgrades, re-validate the config against the new schema","Keep tauri.conf.json churn from local builds restored before committing"],"tags":["json","configuration","tauri","panic"],"backgroundTag":"json-parse-error","analyzedSha":"c8fe8a3f1a115428e3555c06b3de9b7458aa0d54","analyzedAt":"2026-09-20T12:02:36.283Z","contentChangedAt":"2026-09-20T12:02:36.283Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}