{"record":{"id":"86fad3f59a961cae","repo":"tw93/Pake","slug":"failed-to-parse-pake-config","errorCode":null,"errorMessage":"Failed to parse pake config","messagePattern":"Failed to parse pake config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-tauri/src/util.rs","lineNumber":10,"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","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/tw93/Pake/blob/c8fe8a3f1a115428e3555c06b3de9b7458aa0d54/src-tauri/src/util.rs#L1-L28","documentation":"get_pake_config embeds pake.json at compile time (via include_str!) and deserializes it into PakeConfig with serde_json, calling .expect on failure. This panic means the build-time pake.json is not valid JSON or does not match the PakeConfig schema (missing/incorrectly typed required fields).","triggerScenarios":"Building/starting the app where the embedded ../.pake/pake.json (cli-build feature) fails serde deserialization: invalid JSON syntax, unknown/missing required fields, or wrong types.","commonSituations":"The CLI wrote a malformed pake.json during packaging; a hand edit introduced a type error (e.g. width as string); JSON got truncated by a failed write before cargo build.","solutions":["Validate the pake.json referenced by the active feature (src-tauri/.pake/pake.json or src-tauri/pake.json) with a JSON linter and against schema/pake.schema.json.","Regenerate the config via the pake CLI build instead of hand editing.","Rebuild after fixing; the panic message from serde will name the exact offending field."],"exampleFix":"// before (pake.json)\n{ \"windows\": [{ \"url\": \"https://example.com\", \"url_type\": \"web\", \"width\": \"800\" }] }\n// after\n{ \"windows\": [{ \"url\": \"https://example.com\", \"url_type\": \"web\", \"width\": 800 }] }","handlingStrategy":"validation","validationCode":"const Ajv = require('ajv'); const schema = require('./schema/pake.schema.json');\nnew Ajv().validate(schema, JSON.parse(fs.readFileSync('src-tauri/.pake/pake.json'))); // throws on mismatch","typeGuard":"const isPakeConfig = (c) => Array.isArray(c?.windows) && c.windows.every(w => typeof w.url === 'string' && ['web','local'].includes(w.url_type));","tryCatchPattern":"// expect panics cannot be caught in Rust; catch at the packaging layer\ntry { JSON.parse(rawPakeJson); } catch (e) { fail(`pake.json invalid before build: ${e.message}`); }","preventionTips":["Validate generated pake.json against schema/pake.schema.json (tests/unit/config-file.test.ts) before cargo build","Never hand-edit embedded configs; regenerate with the CLI","Ensure file writes are atomic (write temp + rename) so builds never embed truncated JSON"],"tags":["json","configuration","serde","panic"],"backgroundTag":"schema-validation-failed","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"}