{"record":{"id":"512cdb657280f25d","repo":"DioxusLabs/dioxus","slug":"body-element-to-exist","errorCode":null,"errorMessage":"Body element to exist","messagePattern":"Body element to exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop/src/protocol.rs","lineNumber":129,"sourceCode":"    // If the request is for the root, we'll serve the index.html file.\n    if request.uri().path() != \"/\" {\n        return None;\n    }\n\n    // Load a custom index file if provided\n    let mut index = custom_index.unwrap_or_else(|| DEFAULT_INDEX.to_string());\n\n    // Insert a custom head if provided\n    // We look just for the closing head tag. If a user provided a custom index with weird syntax, this might fail\n    if let Some(head) = custom_head {\n        index.insert_str(index.find(\"</head>\").expect(\"Head element to exist\"), &head);\n    }\n\n    // Inject our module loader by looking for a body tag\n    // A failure mode here, obviously, is if the user provided a custom index without a body tag\n    // Might want to document this\n    index.insert_str(\n        index.find(\"</body>\").expect(\"Body element to exist\"),\n        &module_loader(root_name, headless, edit_state),\n    );\n\n    Response::builder()\n        .header(\"Content-Type\", \"text/html\")\n        .header(\"Access-Control-Allow-Origin\", \"*\")\n        .body(index.into())\n        .ok()\n}\n\n/// Construct the inline script that boots up the page and bridges the webview with rust code.\n///\n/// The arguments here:\n/// - root_name: the root element (by Id) that we stream edits into\n/// - headless: is this page being loaded but invisible? Important because not all windows are visible and the\n///   interpreter can't connect until the window is ready.\n/// - port: the port that the websocket server is listening on for edits\n/// - webview_id: the id of the webview that we're loading this into. This is used to differentiate between","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/desktop/src/protocol.rs#L111-L147","documentation":"`index_request` injects custom head content into the served index.html by finding the `</head>` tag and `expect`s it to exist. This panic fires when the user-supplied custom index.html has no closing `</head>` tag — the custom index's syntax is at fault.","triggerScenarios":"Thrown at packages/desktop/src/protocol.rs:129 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure your index.html contains a <body> element; the desktop renderer mounts the app into <body>."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}