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
- Open the .xopp file in Xournal++ and re-save it so all required attributes are written.
- Add a `top="..."` attribute to the offending `<text>` node (find the node id from the error message).
- Check where the file was generated; fix the generator to emit all four bounds attributes.
- 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
- Never hand-edit .xopp files; re-save from Xournal++ instead.
- Validate generated files against all four bounds attributes before importing.
- Fail fast with the node id in your own pre-parser.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse `right` attribute in XoppText with node id
- failed to parse `bottom` attribute in XoppText with node id
- Failed to parse `type` attribute of XoppBackground with…
- failed to parse `tool` attribute in XoppStroke with node id
- failed to parse `color` attribute in XoppStroke with node id
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>()?;
// BottomView on GitHub (pinned to bbc5354502)