{"record":{"id":"6a81f81ddc682435","repo":"tauri-apps/tauri","slug":"unable-to-render-codegen-isolation-script-template","errorCode":null,"errorMessage":"unable to render codegen isolation script template","messagePattern":"unable to render codegen isolation script template","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/html.rs","lineNumber":243,"sourceCode":"///\n/// Note: This function is not considered part of the stable API.\n#[cfg(feature = \"isolation\")]\npub fn inject_codegen_isolation_script(document: &NodeRef) {\n  with_head(document, |head| {\n    let script = NodeRef::new_element(\n      QualName::new(None, ns!(html), \"script\".into()),\n      vec![(\n        ExpandedName::new(ns!(), LocalName::from(\"nonce\")),\n        Attribute {\n          prefix: None,\n          value: SCRIPT_NONCE_TOKEN.into(),\n        },\n      )],\n    );\n    script.append(NodeRef::new_text(\n      IsolationJavascriptCodegen {}\n        .render_default(&Default::default())\n        .expect(\"unable to render codegen isolation script template\")\n        .into_string(),\n    ));\n\n    head.prepend(script);\n  });\n}\n\n/// Temporary workaround for Windows not allowing requests\n///\n/// Note: this does not prevent path traversal due to the isolation application expectation that it\n/// is secure.\npub fn inline_isolation(document: &NodeRef, dir: &Path) {\n  for script in document\n    .select(\"script[src]\")\n    .expect(\"unable to parse document for scripts\")\n  {\n    let src = {\n      let attributes = script.attributes.borrow();","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/html.rs#L225-L261","documentation":"When the Isolation pattern is enabled, `inject_codegen_isolation_script` renders the `IsolationJavascriptCodegen` template via `serialize_to_javascript` and inserts it into the document `<head>`. Template rendering is expected to be infallible (parameters are compile-time); a failure panics with this message.","triggerScenarios":"`serialize_to_javascript::DefaultTemplate::render_default` returning `Err` — practically only from a version mismatch of the `serialize-to-javascript` crate, corrupted cargo build cache, or a broken dependency build.","commonSituations":"Stale/mismatched dependency versions after upgrading Tauri; cargo incremental cache corruption; vendored/offline builds with mismatched crate versions.","solutions":["Run `cargo update -p serialize-to-javascript` (or `cargo update`) to realign dependency versions.","Clean rebuild: `cargo clean && cargo build`.","Verify the `serialize-to-javascript` version matches what your `tauri-utils` version expects in Cargo.lock."],"exampleFix":"// shell fix\ncargo clean && cargo update -p serialize-to-javascript && cargo build","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// render happens at runtime injection; guard the whole injection\nstd::panic::catch_unwind(|| {\n  tauri::utils::html::inject_codegen_isolation_script(&document);\n}).unwrap_or_else(|_| eprintln!(\"isolation script injection failed\"));","preventionTips":["Keep serialize-to-javascript versions aligned with your tauri crates (single Cargo.lock).","Run cargo clean after upgrading Tauri.","Avoid overriding transitive dependency versions in [patch] sections."],"tags":["isolation-pattern","codegen","template","panic"],"backgroundTag":"internal-invariant-violation","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"}