flxzt/rnote · error

failed to parse width attribute of XoppPage for node with id

Error message

failed to parse width attribute of XoppPage for node with id {:?}, could not find attribute

What it means

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.

Solutions

  1. Open the .xopp file in Xournal++ and re-save it to regenerate valid attributes
  2. Add the missing width attribute to the <page> element (e.g. width="793.7007874015748")
  3. Regenerate the file from its source tool with proper page dimensions
  4. Validate the XML against the xopp format before loading

Example fix

// before
<page>
  <background .../>
</page>
// after
<page width="793.7007874015748" height="1122.5196850393701">
  <background .../>
</page>
Defensive patterns

Strategy: validation

Validate before calling

fn page_has_dimensions(node: &roxmltree::Node) -> bool {
    node.attribute("width").is_some() && node.attribute("height").is_some()
}

Try / catch

match xopp_page.load_from_xml(page_node) {
    Err(e) if e.to_string().contains("width attribute") => {
        // supply default page width and continue or report
    }
    other => other,
}

Prevention

When it happens

Trigger: 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.

Common situations: Importing a .xopp file produced by third-party generators or older/modified Xournal++ versions; corrupted XML where attributes were dropped; template files edited manually.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

/// A Xopp Page.
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct XoppPage {
    /// The width of the page.
    pub width: f64,
    /// The height of the page.
    pub height: f64,
    /// The Background of the page.
    pub background: XoppBackground,
    /// The layers of the page.
    pub layers: Vec<XoppLayer>,
}

impl XmlLoadable for XoppPage {
    fn load_from_xml(&mut self, node: Node) -> anyhow::Result<()> {
        self.width = node
            .attribute("width")
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "failed to parse width attribute of XoppPage for node with id {:?}, could not find attribute",
                    node.id()
                )
            })?
            .parse::<f64>()?;

        self.height = node
            .attribute("height")
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "failed to parse height attribute of XoppPage with node id {:?}, could not find attribute",
                    node.id()
                )
            })?
            .parse::<f64>()?;

        for child in node.children() {
            match child.node_type() {

View on GitHub (pinned to bbc5354502)