{"record":{"id":"936b3f155b5b1848","repo":"tauri-apps/tauri","slug":"unable-to-render-codegen-isolation-script-template-html2","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/html2.rs","lineNumber":120,"sourceCode":"}\n\n/// Injects the Isolation JavaScript to a codegen time document.\n///\n/// Note: This function is not considered part of the stable API.\n///\n/// # Stability\n///\n/// This dependency [`dom_query`] for [`Document`] might receive updates in minor releases.\n#[cfg(feature = \"isolation\")]\npub fn inject_codegen_isolation_script(document: &Document) {\n  use crate::pattern::isolation::IsolationJavascriptCodegen;\n  use serialize_to_javascript::DefaultTemplate;\n\n  let head = ensure_head(document);\n\n  let script_content = IsolationJavascriptCodegen {}\n    .render_default(&Default::default())\n    .expect(\"unable to render codegen isolation script template\")\n    .into_string();\n\n  let script_tag = document.tree.new_element(\"script\");\n  script_tag.set_attr(\"nonce\", SCRIPT_NONCE_TOKEN);\n  script_tag.set_text(script_content);\n\n  head.prepend_child(&script_tag);\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.\n///\n/// # Stability\n///\n/// This dependency [`dom_query`] for [`Document`] might receive updates in minor releases.\n#[cfg(feature = \"isolation\")]","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/html2.rs#L102-L138","documentation":"Same failure as the html.rs variant but in the alternate `html2` implementation: `inject_codegen_isolation_script` renders the `IsolationJavascriptCodegen` template with `serialize_to_javascript` before injecting a nonce-tagged `<script>`; render failure panics with this message.","triggerScenarios":"`IsolationJavascriptCodegen::render_default` returning `Err` during isolation-pattern HTML injection — effectively only from `serialize-to-javascript` version mismatch or corrupted build artifacts.","commonSituations":"After upgrading Tauri crates with a stale Cargo.lock; cargo cache corruption; mixed crate versions in a workspace.","solutions":["Run `cargo update -p serialize-to-javascript` to align versions.","Do a clean rebuild (`cargo clean && cargo build`).","Confirm no workspace dependency pins override `serialize-to-javascript`."],"exampleFix":"// shell fix\ncargo clean && cargo update -p serialize-to-javascript && cargo build","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// guard the html2 injection path\nstd::panic::catch_unwind(|| {\n  tauri::utils::html2::inject_codegen_isolation_script(&document);\n}).unwrap_or_else(|_| eprintln!(\"isolation script injection failed (html2)\"));","preventionTips":["Keep a single aligned Cargo.lock across workspace tauri crates.","cargo clean after version upgrades.","Prefer the primary html.rs path unless html2 is intentional; keep both on the same dependency versions."],"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"}