flxzt/rnote · error

failed to parse `right` attribute in XoppText with node id

Error message

failed to parse `right` attribute in XoppText with node id {:?}, could not find attribute

What it means

Thrown when a `<text>` element in a .xopp file has no `right` attribute during XoppText parsing. The parser needs all four bounds (top/left/right/bottom) to reconstruct the text's rectangle; missing `right` means the document is malformed.

Solutions

  1. Re-save the file with Xournal++ to regenerate complete bounds attributes.
  2. Add `right="..."` to the `<text>` node with the id shown in the error.
  3. Fix the external generator to emit top/left/right/bottom on every text element.
  4. Validate the xopp XML against expected text-element attributes before importing.

Example fix

// before
<text left="50.0" top="100.0">...</text>
// after
<text left="50.0" top="100.0" right="200.0" bottom="150.0">...</text>
Defensive patterns

Strategy: validation

Validate before calling

// rust
fn text_node_has_bounds(node: &roxmltree::Node) -> bool {
    ["top", "left", "right", "bottom"].iter().all(|a| node.attribute(a).is_some())
}

Type guard

fn get_f64_attr(node: &roxmltree::Node, name: &str) -> Option<f64> {
    node.attribute(name).and_then(|v| v.parse::<f64>().ok())
}

Try / catch

match xopp_file.parse() {
    Ok(doc) => doc,
    Err(e) if e.to_string().contains("`right`") => {
        eprintln!(".xopp text node missing 'right' attribute: {e}");
    }
}

Prevention

When it happens

Trigger: Loading a .xopp file whose `<text>` node lacks a `right` XML attribute via the xopp format importer.

Common situations: Files generated by custom scripts that only write x/y position; hand-edited documents; older or incompatible Xournal++ file variants.

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/d00bdb9228bf4fdb. Report an issue: GitHub.

Appendix: source

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

            })?
            .parse::<f64>()?;

        // Top
        self.top = node
            .attribute("top")
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "failed to parse `top` attribute in XoppText with node id {:?}, could not find attribute",
                    node.id()
                )
            })?
            .parse::<f64>()?;

        // Right
        self.right = node
            .attribute("right")
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "failed to parse `right` attribute in XoppText with node id {:?}, could not find attribute",
                    node.id()
                )
            })?
            .parse::<f64>()?;

        // Bottom
        self.bottom = node
            .attribute("bottom")
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "failed to parse `bottom` attribute in XoppText with node id {:?}, could not find attribute",
                    node.id()
                )
            })?
            .parse::<f64>()?;

        // Data

View on GitHub (pinned to bbc5354502)