flxzt/rnote · error

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

Error message

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

What it means

Thrown when a `<text>` element in a Xournal++ (.xopp) file has no `top` attribute while its coordinate bounds are being parsed into XoppText. The xopp parser requires every text element to carry explicit top/left/right/bottom bounds; a missing attribute is treated as a corrupt or incomplete document.

Solutions

  1. Open the .xopp file in Xournal++ and re-save it so all required attributes are written.
  2. Add a `top="..."` attribute to the offending `<text>` node (find the node id from the error message).
  3. Check where the file was generated; fix the generator to emit all four bounds attributes.
  4. Wrap the import in error handling and surface a 'corrupt xopp file' message to the user.

Example fix

// before (hand-edited xopp)
<text>...</text>
// after
<text top="100.0" left="50.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("could not find attribute") => {
        eprintln!("corrupt .xopp file, missing bounds attribute: {e}");
        // offer re-save / recovery path
    }
}

Prevention

When it happens

Trigger: Parsing a .xopp file whose `<text>` node lacks a `top` XML attribute; calling the XoppFile format loader on a hand-edited or truncated file.

Common situations: Hand-edited or programmatically generated .xopp files missing bounds attributes; files produced by third-party tools that only emit partial coordinates; truncated/corrupted downloads.

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

Appendix: source

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

impl XmlLoadable for XoppImage {
    fn load_from_xml(&mut self, node: Node) -> anyhow::Result<()> {
        // Left
        self.left = node
            .attribute("left")
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "failed to parse `left` attribute in XoppText with node id {:?}, could not find attribute",
                    node.id()
                )
            })?
            .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

View on GitHub (pinned to bbc5354502)