flxzt/rnote · error

Err while parsing `style` attribute of XoppBackground with…

Error message

Err while parsing `style` attribute of XoppBackground with node id {:?}, is not a valid value

What it means

XML parsing error in XoppBackground::load_from_xml: the `style` attribute of a solid background could not be parsed into a valid style value, so the background is rejected during .xopp import. The style attribute is missing or not one of the accepted values.

Solutions

  1. Correct the `style` attribute on the background node to a value Xournal++ writes (plain, lined, ruled, dotted, graph, isodotted, etc.).
  2. Re-export the file from Xournal++ to normalize the attribute.
  3. Remove the style or convert the background manually if it is unsupported by rnote's importer.

Example fix

// before
<background type="pixmap" domain="relative" filename="bg.png"/>
// after
<background type="pixmap" domain="absolute" filename="bg.png"/>
Defensive patterns

Strategy: validation

Validate before calling

fn pixmap_domain_known(node: &roxmltree::Node) -> bool {
    matches!(node.attribute("domain"), Some("absolute") | Some("attach") | Some("clone"))
}

Try / catch

match domain_value {
    "absolute" => ..., "attach" => ..., "clone" => ...,
    other => {
        warn!("unknown domain {}, defaulting to absolute", other);
        ...
    }
}

Prevention

When it happens

Trigger: load_from_xml on a <background type="pixmap"> whose domain is present but unrecognized, e.g. domain="relative" or a newer Xournal++ domain value.

Common situations: Files from newer Xournal++ with extra domain modes; typos like 'absoulte'; custom tools inventing domain values.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/9e4ea3e236d19400. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-engine/src/fileformats/xoppformat.rs:398

                let color = XoppColor::from_backgroundcolor_attr_value(
                    node.attribute("color").ok_or_else(|| {
                        anyhow::anyhow!(
                            "Failed to parse `color` attribute in XoppBackground with id {:?}",
                            node.id()
                        )
                    })?,
                )?;
                self.bg_type = XoppBackgroundType::Solid { color, style };
            }
            "pixmap" => {
                let domain = match node.attribute("domain").ok_or_else(|| {
                    anyhow::anyhow!("Failed to parse `domain` attribute in XoppBackground with node id {:?}, could not find attribute", node.id())
                })? {
                    "absolute" => XoppBackgroundPixmapDomain::Absolute,
                    "attach" => XoppBackgroundPixmapDomain::Attach,
                    "clone" => XoppBackgroundPixmapDomain::Clone,
                    _ => {
                        return Err(anyhow::anyhow!("Err while parsing `style` attribute of XoppBackground with node id {:?}, is not a valid value", node.id()));
                    }
                };
                let filename = node
                    .attribute("filename")
                    .ok_or_else(|| {
                        anyhow::anyhow!("Failed to parse `filename` attribute in XoppBackground with node id {:?}, could not find attribute", node.id())
                    })?
                    .to_string();
                self.bg_type = XoppBackgroundType::Pixmap { domain, filename };
            }
            "pdf" => {
                self.bg_type = XoppBackgroundType::Pdf;
            }
            _ => {
                return Err(anyhow::anyhow!("Failed to parse `type` attribute of XoppBackground with node id {:?}, is not a valid value", node.id()));
            }
        }

View on GitHub (pinned to bbc5354502)