{"record":{"id":"4ba39b37e8e665c3","repo":"flxzt/rnote","slug":"failed-to-parse-size-attribute-in-xopptext-with","errorCode":null,"errorMessage":"failed to parse `size` attribute in XoppText with node id {:?}, could not find attribute","messagePattern":"failed to parse `size` attribute in XoppText with node id (.+?), could not find attribute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/xoppformat.rs","lineNumber":877,"sourceCode":"    pub text: String,\n}\n\nimpl XmlLoadable for XoppText {\n    fn load_from_xml(&mut self, node: Node) -> anyhow::Result<()> {\n        self.font = node\n            .attribute(\"font\")\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"failed to parse `font` attribute in XoppText with node id {:?}, could not find attribute\",\n                    node.id()\n                )\n            })?\n            .to_string();\n\n        self.size = node\n            .attribute(\"size\")\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"failed to parse `size` attribute in XoppText with node id {:?}, could not find attribute\",\n                    node.id()\n                )\n            })?\n            .parse::<f64>()?;\n\n        self.x = node\n            .attribute(\"x\")\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"failed to parse `x` attribute in XoppText with node id {:?}, could not find attribute\",\n                    node.id()\n                )\n            })?\n            .parse::<f64>()?;\n\n        self.y = node\n            .attribute(\"y\")","sourceCodeStart":859,"sourceCodeEnd":895,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/xoppformat.rs#L859-L895","documentation":"Thrown by XoppText::load_from_xml when a `<text>` element has no `size` attribute. The value is parsed as f64 into XoppText.size, and since font size is mandatory in the XOPP text schema, its absence raises this anyhow error with the node id.","triggerScenarios":"Importing a .xopp file whose <text> element is missing the `size` attribute (external generation, hand edits, corruption). Note the error also fires if parse::<f64>() of the value fails, but the primary documented case is the missing attribute.","commonSituations":"Scripts writing text elements without size; manual XML edits; files produced by older/incompatible exporters.","solutions":["Add size to the <text> element, e.g. size=\"12.0\".","Regenerate the file ensuring all required text attributes (font, size, x, y, color) are present.","Re-save via Xournal++ to normalize the XML, then retry import."],"exampleFix":"// before (file XML)\n<text font=\"Sans\" x=\"10\" y=\"20\">Hello</text>\n// after (file XML)\n<text font=\"Sans\" size=\"12\" x=\"10\" y=\"20\">Hello</text>","handlingStrategy":"validation","validationCode":"fn text_sizes_parse(xml: &str) -> Result<(), String> {\n    for (i, chunk) in xml.split(\"<text\").skip(1).enumerate() {\n        let head = chunk.split('>').next().unwrap_or(\"\");\n        match head.split(\"size=\\\"\").nth(1).and_then(|r| r.split('\\\"').next()) {\n            Some(v) if v.parse::<f64>().is_err() => return Err(format!(\"text #{i} size not a number: {v}\")),\n            None => return Err(format!(\"text #{i} missing `size` attribute\")),\n            _ => {}\n        }\n    }\n    Ok(())\n}","typeGuard":"fn has_numeric_attr(attrs: &[(&str, &str)], name: &str) -> bool {\n    attrs.iter().any(|(k, v)| *k == name && v.parse::<f64>().is_ok())\n}","tryCatchPattern":"match import_xopp(path) {\n    Err(e) if e.to_string().contains(\"`size` attribute in XoppText\") => {\n        eprintln!(\"Text element missing/invalid size; fix XML or re-save in Xournal++: {e:#}\");\n    }\n    Err(e) => eprintln!(\"import failed: {e:#}\"),\n    Ok(doc) => { /* proceed */ }\n}","preventionTips":["Write size as a plain numeric value (no units) in generated files","Pre-validate numeric attributes parse as f64 before import","Re-save via Xournal++ when attribute formats look nonstandard"],"tags":["parsing","xml","missing-attribute","xopp"],"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"}