{"record":{"id":"26b0fda70744841d","repo":"flxzt/rnote","slug":"failed-to-parse-type-attribute-of-xoppbackground-26b0fd","errorCode":null,"errorMessage":"Failed to parse `type` attribute of XoppBackground with node id {:?}, is not a valid value","messagePattern":"Failed to parse `type` attribute of XoppBackground with node id (.+?), is not a valid value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/xoppformat.rs","lineNumber":413,"sourceCode":"                    \"attach\" => XoppBackgroundPixmapDomain::Attach,\n                    \"clone\" => XoppBackgroundPixmapDomain::Clone,\n                    _ => {\n                        return Err(anyhow::anyhow!(\"Err while parsing `style` attribute of XoppBackground with node id {:?}, is not a valid value\", node.id()));\n                    }\n                };\n                let filename = node\n                    .attribute(\"filename\")\n                    .ok_or_else(|| {\n                        anyhow::anyhow!(\"Failed to parse `filename` attribute in XoppBackground with node id {:?}, could not find attribute\", node.id())\n                    })?\n                    .to_string();\n                self.bg_type = XoppBackgroundType::Pixmap { domain, filename };\n            }\n            \"pdf\" => {\n                self.bg_type = XoppBackgroundType::Pdf;\n            }\n            _ => {\n                return Err(anyhow::anyhow!(\"Failed to parse `type` attribute of XoppBackground with node id {:?}, is not a valid value\", node.id()));\n            }\n        }\n\n        Ok(())\n    }\n}\n\nimpl XmlWritable for XoppBackground {\n    fn write_to_xml(&self, w: &mut xmlwriter::XmlWriter) {\n        w.start_element(\"background\");\n        if let Some(name) = self.name.as_ref() {\n            w.write_attribute(\"name\", name.as_str());\n        }\n        self.bg_type.write_to_xml(w);\n        w.end_element()\n    }\n}\n","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/xoppformat.rs#L395-L431","documentation":"This error is thrown while loading the `<background>` XML element of a Xournal++ (.xopp) file: the `type` attribute held a value that rnote does not recognize. The parser matches the attribute against a fixed set of known background types (e.g. \"plain\", \"lined\", \"pixmap\", \"pdf\") and falls into the `_` catch-all arm when none match, aborting the file load.","triggerScenarios":"Calling XoppBackground::load_from_xml (via xopp file import) on a `<background type=\"...\">` element whose type attribute is an unknown/unexpected string, e.g. an old or newer Xournal++ format version introducing a background type rnote's importer does not support, a hand-edited file with a typo like type=\"gridd\", or a corrupted file where the attribute value was mangled.","commonSituations":"Importing .xopp files saved by a different Xournal++ version than the formats rnote's importer targets; hand-edited or template-generated xopp files with nonstandard background types; locale/corruption issues changing the attribute text.","solutions":["Open the .xopp file in Xournal++ itself and re-save it so the background uses a standard type rnote supports (plain, lined, ruled, graph, pixmap, pdf).","Inspect the `<background type=\"...\">` element in the file (unzip/edit XML) and correct or remove the unknown type value.","Re-export the file from Xournal++ to the latest stable .xopp format and retry the import.","If the type is legitimately new in a newer Xournal++ release, add it to the match in XoppBackground::load_from_xml and map it to an rnote background type."],"exampleFix":"// before (file XML)\n<background type=\"gridd\" style=\"blue:1:10:10\" />\n// after (file XML)\n<background type=\"graph\" style=\"blue:1:10:10\" />","handlingStrategy":"validation","validationCode":"const KNOWN_BG_TYPES: [&str; 5] = [\"plain\", \"lined\", \"ruled\", \"graph\", \"pixmap\"];\nfn background_type_supported(doc: &str) -> bool {\n    doc.contains(\"<background\") && doc.split(\"type=\\\"\").nth(1)\n        .map(|rest| KNOWN_BG_TYPES.iter().any(|t| rest.starts_with(t)))\n        .unwrap_or(true) // pdf handled separately\n}","typeGuard":"fn is_valid_bg_type(v: &str) -> bool {\n    matches!(v, \"plain\" | \"lined\" | \"ruled\" | \"graph\" | \"pixmap\" | \"pdf\")\n}","tryCatchPattern":"// pre-validate the file before import\nif !is_valid_bg_type(extract_background_type(&xopp_xml)) {\n    eprintln!(\"Unsupported Xournal++ background type; re-save via Xournal++ first\");\n} else {\n    match rnote_import(&path) {\n        Err(e) => eprintln!(\"import failed: {e:#}\"),\n        Ok(doc) => { /* use doc */ }\n    }\n}","preventionTips":["Only import .xopp files saved by a Xournal++ version matching what rnote's importer targets","Never hand-edit xopp XML background types; re-save via Xournal++ instead","Sanity-check imported files by opening them in Xournal++ before import","Handle the failure at import level so one bad file doesn't abort a batch"],"tags":["parsing","xml","file-import","xopp"],"backgroundTag":"invalid-enum-value","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}