flxzt/rnote · error
failed to parse `y` attribute in XoppText with node id
Error message
failed to parse `y` attribute in XoppText with node id {:?}, could not find attribute What it means
Thrown by XoppText::load_from_xml when a `<text>` element has no `y` attribute. The y coordinate (f64) is required to place the text; its absence aborts parsing with this anyhow error including the XML node id.
Solutions
- Add a y attribute to the <text> element, e.g. y="50.0".
- Regenerate the file with all required text attributes present.
- Open in Xournal++, re-save, and re-import the repaired file.
Example fix
// before (file XML) <text font="Sans" size="12" x="100">Hello</text> // after (file XML) <text font="Sans" size="12" x="100" y="50">Hello</text>
Defensive patterns
Strategy: validation
Validate before calling
fn text_has_y(xml: &str) -> Result<(), String> {
for (i, chunk) in xml.split("<text").skip(1).enumerate() {
let head = chunk.split('>').next().unwrap_or("");
if !head.contains("y=") {
return Err(format!("text #{i} missing `y` attribute"));
}
}
Ok(())
} Type guard
fn has_numeric_attr(attrs: &[(&str, &str)], name: &str) -> bool {
attrs.iter().any(|(k, v)| *k == name && v.parse::<f64>().is_ok())
} Try / catch
match import_xopp(path) {
Err(e) if e.to_string().contains("`y` attribute in XoppText") => {
eprintln!("Text element missing y coordinate; add it or re-save in Xournal++: {e:#}");
}
Err(e) => eprintln!("import failed: {e:#}"),
Ok(doc) => { /* proceed */ }
} Prevention
- Emit both x and y for every text element; never write only one coordinate
- Pre-validate required numeric attributes before import
- Round-trip generated files through Xournal++ to catch omissions
When it happens
Trigger: Importing a .xopp file whose <text> element lacks the `y` attribute, e.g. produced by scripts or manual edits that dropped coordinate attributes.
Common situations: Custom exporters omitting y; hand-edited XML; damaged or truncated files.
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 `tool` attribute in XoppStroke with node id
- failed to parse `color` attribute in XoppStroke with node id
- failed to parse `width` attribute in XoppStroke with node id
- failed to parse `font` attribute in XoppText with node id
- failed to parse `size` attribute in XoppText with node id
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/32a1625d7874a44e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-engine/src/fileformats/xoppformat.rs:897
node.id()
)
})?
.parse::<f64>()?;
self.x = node
.attribute("x")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse `x` attribute in XoppText with node id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
self.y = node
.attribute("y")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse `y` attribute in XoppText with node id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
self.color =
XoppColor::from_strokecolor_attr_value(node.attribute("color").ok_or_else(|| {
anyhow::anyhow!(
"failed to parse `color` attribute in XoppText with node id {:?}, could not find attribute",
node.id()
)
})?)?;
if let Some(text) = node.text() {
self.text = text.to_string();
}
View on GitHub (pinned to bbc5354502)