{"record":{"id":"f0646de61e3cfe94","repo":"tauri-apps/tauri","slug":"unable-to-parse-document-for-scripts","errorCode":null,"errorMessage":"unable to parse document for scripts","messagePattern":"unable to parse document for scripts","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-utils/src/html.rs","lineNumber":258,"sourceCode":"    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();\n      attributes\n        .get(LocalName::from(\"src\"))\n        .expect(\"script with src attribute has no src value\")\n        .to_string()\n    };\n\n    let mut path = PathBuf::from(src);\n    if path.has_root() {\n      path = path\n        .strip_prefix(\"/\")\n        .expect(\"Tauri \\\"Isolation\\\" Pattern only supports relative or absolute (`/`) paths.\")\n        .into();\n    }\n\n    let file = std::fs::read_to_string(dir.join(path)).expect(\"unable to find isolation file\");","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-utils/src/html.rs#L240-L276","documentation":"`inline_isolation` walks the parsed HTML document and calls `document.select(\"script[src]\")` to find external scripts. `select` only errors for an invalid CSS selector; since the selector is a constant valid string, this panic indicates an internal invariant break in the html parsing setup.","triggerScenarios":"Practically unreachable from user input — triggered only if the scraper/html5ever `select` API rejects the built-in selector, i.e. a library bug or incompatible scraper version.","commonSituations":"Dependency version drift where `tauri-utils` is compiled against an incompatible `scraper` API; custom forks patching html.rs.","solutions":["Rebuild with aligned dependency versions (`cargo update`, then `cargo clean`).","Check that you are not overriding the `scraper` dependency version in Cargo.toml.","Report to Tauri if it reproduces on stock versions."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// defensively wrap document processing\nif std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n  tauri::utils::html::inline_isolation(&document, &dir);\n})).is_err() { eprintln!(\"isolation inlining failed\"); }","preventionTips":["Use stock, unpatched tauri-utils with its matching scraper dependency.","Do not hand-edit html.rs selector logic.","Pin dependency versions in Cargo.lock for reproducible builds."],"tags":["isolation-pattern","html","parser","internal"],"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"}