{"record":{"id":"5ce03dc451ad07d7","repo":"tauri-apps/tauri","slug":"failed-to-parse-capabilities","errorCode":null,"errorMessage":"failed to parse capabilities","messagePattern":"failed to parse capabilities","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-codegen/src/context.rs","lineNumber":408,"sourceCode":"        crypto_keys: std::boxed::Box::new(::tauri::utils::pattern::isolation::Keys::new().expect(\"unable to generate cryptographically secure keys for Tauri \\\"Isolation\\\" Pattern\")),\n      })\n    }\n  };\n\n  let acl_file_path = out_dir.join(ACL_MANIFESTS_FILE_NAME);\n  let acl: BTreeMap<String, Manifest> = if acl_file_path.exists() {\n    let acl_file =\n      std::fs::read_to_string(acl_file_path).expect(\"failed to read plugin manifest map\");\n    serde_json::from_str(&acl_file).expect(\"failed to parse plugin manifest map\")\n  } else {\n    Default::default()\n  };\n\n  let capabilities_file_path = out_dir.join(CAPABILITIES_FILE_NAME);\n  let capabilities_from_files = if capabilities_file_path.exists() {\n    let capabilities_json =\n      std::fs::read_to_string(&capabilities_file_path).expect(\"failed to read capabilities\");\n    serde_json::from_str(&capabilities_json).expect(\"failed to parse capabilities\")\n  } else {\n    Default::default()\n  };\n  let capabilities = get_capabilities(\n    &config,\n    capabilities_from_files,\n    additional_capabilities.as_deref(),\n  )\n  .unwrap();\n\n  let resolved = Resolved::resolve(&acl, capabilities, target).expect(\"failed to resolve ACL\");\n\n  let acl_tokens = map_lit(\n    quote! { ::std::collections::BTreeMap },\n    &acl,\n    str_lit,\n    identity,\n  );","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-codegen/src/context.rs#L390-L426","documentation":"Thrown at build time when the generated capabilities file was read but `serde_json::from_str` fails to deserialize it into the expected capabilities structure. The JSON is malformed or its schema does not match what the current tauri version expects — typically a truncated or stale file from an interrupted or mismatched-version build.","triggerScenarios":"`tauri build`/`tauri dev` with a corrupted/truncated capabilities.json in the out dir, or one generated by an incompatible tauri CLI version whose capability schema differs.","commonSituations":"Interrupted builds (Ctrl-C during write); version mismatch between @tauri-apps/cli and tauri crates; manual edits to generated files; partial writes on disk-full.","solutions":["Delete the capabilities file or `cargo clean` and rebuild to regenerate it.","Align the tauri CLI version with your tauri crate versions (npm/pnpm and Cargo.toml).","Validate the JSON to confirm the corruption, then regenerate rather than editing it by hand.","If defining capabilities, validate your capabilities/*.json files against the schema in your Tauri version."],"exampleFix":"// before (truncated generated capabilities.json)\n{\"windows\": {}\n// after: regenerate via clean build\ncargo clean && cargo tauri build","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst file = 'src-tauri/target/<profile>/build/<hash>/out/capabilities.json';\nif (fs.existsSync(file)) {\n  try {\n    const caps = JSON.parse(fs.readFileSync(file, 'utf8'));\n    if (!caps || typeof caps !== 'object') throw new Error('not an object');\n  } catch (e) { console.error('stale/corrupted capabilities.json — cargo clean and rebuild'); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep @tauri-apps/cli and Cargo tauri versions in sync","Validate your own capabilities/*.json against the Tauri schema in CI","Never manually edit generated files in target/","cargo clean after interrupted builds"],"tags":["build-time","json","serialization","tauri","capabilities"],"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"}