{"record":{"id":"6d06a1a65c3aaec2","repo":"flxzt/rnote","slug":"failed-to-parse-filename-attribute-in-xoppbackgr","errorCode":null,"errorMessage":"Failed to parse `filename` attribute in XoppBackground with node id {:?}, could not find attribute","messagePattern":"Failed to parse `filename` attribute in XoppBackground with node id (.+?), could not find attribute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/xoppformat.rs","lineNumber":404,"sourceCode":"                    })?,\n                )?;\n                self.bg_type = XoppBackgroundType::Solid { color, style };\n            }\n            \"pixmap\" => {\n                let domain = match node.attribute(\"domain\").ok_or_else(|| {\n                    anyhow::anyhow!(\"Failed to parse `domain` attribute in XoppBackground with node id {:?}, could not find attribute\", node.id())\n                })? {\n                    \"absolute\" => XoppBackgroundPixmapDomain::Absolute,\n                    \"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) {","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/xoppformat.rs#L386-L422","documentation":"A pixmap XoppBackground must carry a 'filename' attribute pointing to the embedded/background image. When it is missing, load_from_xml returns this error and the pixmap background cannot be constructed.","triggerScenarios":"load_from_xml on a <background type=\"pixmap\"> node with valid domain but no 'filename' attribute.","commonSituations":"Files where the background element was hand-edited or partially regenerated; tools that emit pixmap backgrounds without the image reference; lost attributes during XML round-tripping.","solutions":["Add filename=\"...\" referencing the background image (for domain=\"absolute\" the path must be resolvable)","Re-save the file in Xournal++ with the image background intact","Ensure the referenced image file exists at the expected location","When generating xopp XML, always emit domain + filename together for pixmap backgrounds"],"exampleFix":"// before\n<background type=\"pixmap\" domain=\"absolute\"/>\n// after\n<background type=\"pixmap\" domain=\"absolute\" filename=\"bg.png\"/>","handlingStrategy":"validation","validationCode":"fn pixmap_bg_resolvable(node: &roxmltree::Node) -> bool {\n    node.attribute(\"filename\")\n        .map(|f| std::path::Path::new(f).exists())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"let filename = match node.attribute(\"filename\") {\n    Some(f) => f.to_string(),\n    None => bail!(\"pixmap background missing filename\"),\n};","preventionTips":["Always pair type=\"pixmap\" with domain and filename","Verify the referenced image exists (absolute domain) before load","Keep image assets bundled when round-tripping xopp archives"],"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"}