{"record":{"id":"ce487ea7524d95f5","repo":"flxzt/rnote","slug":"failed-to-parse-width-attribute-of-xopppage-for-no","errorCode":null,"errorMessage":"failed to parse width attribute of XoppPage for node with id {:?}, could not find attribute","messagePattern":"failed to parse width attribute of XoppPage for node with id (.+?), could not find attribute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/xoppformat.rs","lineNumber":153,"sourceCode":"/// A Xopp Page.\n#[derive(Default, Debug, Clone, Serialize, Deserialize)]\npub struct XoppPage {\n    /// The width of the page.\n    pub width: f64,\n    /// The height of the page.\n    pub height: f64,\n    /// The Background of the page.\n    pub background: XoppBackground,\n    /// The layers of the page.\n    pub layers: Vec<XoppLayer>,\n}\n\nimpl XmlLoadable for XoppPage {\n    fn load_from_xml(&mut self, node: Node) -> anyhow::Result<()> {\n        self.width = node\n            .attribute(\"width\")\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"failed to parse width attribute of XoppPage for node with id {:?}, could not find attribute\",\n                    node.id()\n                )\n            })?\n            .parse::<f64>()?;\n\n        self.height = node\n            .attribute(\"height\")\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"failed to parse height attribute of XoppPage with node id {:?}, could not find attribute\",\n                    node.id()\n                )\n            })?\n            .parse::<f64>()?;\n\n        for child in node.children() {\n            match child.node_type() {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/xoppformat.rs#L135-L171","documentation":"While parsing a Xournal++ (.xopp) XML document, the <page> element lacked a required 'width' attribute. XoppPage::load_from_xml treats width as mandatory and returns an error when roxmltree's attribute lookup returns None.","triggerScenarios":"Calling load_from_xml on a <page> node without a 'width' attribute, e.g. loading a .xopp file whose page element is hand-edited, generated by a non-conforming tool, or truncated.","commonSituations":"Importing a .xopp file produced by third-party generators or older/modified Xournal++ versions; corrupted XML where attributes were dropped; template files edited manually.","solutions":["Open the .xopp file in Xournal++ and re-save it to regenerate valid attributes","Add the missing width attribute to the <page> element (e.g. width=\"793.7007874015748\")","Regenerate the file from its source tool with proper page dimensions","Validate the XML against the xopp format before loading"],"exampleFix":"// before\n<page>\n  <background .../>\n</page>\n// after\n<page width=\"793.7007874015748\" height=\"1122.5196850393701\">\n  <background .../>\n</page>","handlingStrategy":"validation","validationCode":"fn page_has_dimensions(node: &roxmltree::Node) -> bool {\n    node.attribute(\"width\").is_some() && node.attribute(\"height\").is_some()\n}","typeGuard":null,"tryCatchPattern":"match xopp_page.load_from_xml(page_node) {\n    Err(e) if e.to_string().contains(\"width attribute\") => {\n        // supply default page width and continue or report\n    }\n    other => other,\n}","preventionTips":["Validate xopp XML attributes before import","Re-save suspect files in Xournal++","Never hand-edit .xopp XML without both width and height present"],"tags":["xml-parsing","file-formats","xopp","rust"],"backgroundTag":"missing-required-argument","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}