tw93/Pake · critical

Failed to parse pake config

Error message

Failed to parse pake config

What it means

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).

Solutions

  1. 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.
  2. Regenerate the config via the pake CLI build instead of hand editing.
  3. Rebuild after fixing; the panic message from serde will name the exact offending field.

Example fix

// before (pake.json)
{ "windows": [{ "url": "https://example.com", "url_type": "web", "width": "800" }] }
// after
{ "windows": [{ "url": "https://example.com", "url_type": "web", "width": 800 }] }
Defensive patterns

Strategy: validation

Validate before calling

const Ajv = require('ajv'); const schema = require('./schema/pake.schema.json');
new Ajv().validate(schema, JSON.parse(fs.readFileSync('src-tauri/.pake/pake.json'))); // throws on mismatch

Type guard

const isPakeConfig = (c) => Array.isArray(c?.windows) && c.windows.every(w => typeof w.url === 'string' && ['web','local'].includes(w.url_type));

Try / catch

// expect panics cannot be caught in Rust; catch at the packaging layer
try { JSON.parse(rawPakeJson); } catch (e) { fail(`pake.json invalid before build: ${e.message}`); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of tw93/Pake@c8fe8a3f1a (2026-09-20). Data as JSON: /api/errors/86fad3f59a961cae. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/src/util.rs:10

use crate::app::config::PakeConfig;
use crate::app::window::MultiWindowState;
use std::env;
use std::path::{Path, PathBuf};
use tauri::{AppHandle, Config, Manager, WebviewWindow};

pub fn get_pake_config() -> (PakeConfig, Config) {
    #[cfg(feature = "cli-build")]
    let pake_config: PakeConfig = serde_json::from_str(include_str!("../.pake/pake.json"))
        .expect("Failed to parse pake config");

    #[cfg(not(feature = "cli-build"))]
    let pake_config: PakeConfig =
        serde_json::from_str(include_str!("../pake.json")).expect("Failed to parse pake config");

    #[cfg(feature = "cli-build")]
    let tauri_config: Config = serde_json::from_str(include_str!("../.pake/tauri.conf.json"))
        .expect("Failed to parse tauri config");

    #[cfg(not(feature = "cli-build"))]
    let tauri_config: Config = serde_json::from_str(include_str!("../tauri.conf.json"))
        .expect("Failed to parse tauri config");

    (pake_config, tauri_config)
}

pub fn get_data_dir(app: &AppHandle, package_name: String) -> std::io::Result<PathBuf> {
    let data_dir = app

View on GitHub (pinned to c8fe8a3f1a)