flxzt/rnote · error · anyhow::Error
image does not contain 'rectangle'.
Error message
image does not contain 'rectangle'.
What it means
Thrown in TryFrom<RnoteFileMaj0Min13>::try_from when bitmapimage.image is an object but lacks the 'rectangle' key. The migration converts the legacy transform stored under the rectangle into the new affine representation, so the rectangle is mandatory during the maj0min13 -> maj0min15 upgrade.
Solutions
- Re-add the 'rectangle' object (with its legacy 'transform') to bitmapimage.image in the file JSON.
- Restore the note from a backup and re-save it via the app.
- Validate legacy files against the maj0min13 schema before migration to catch missing rectangles early.
- Adjust the migration to warn and skip bitmap strokes lacking rectangle instead of aborting the whole file.
Example fix
// before
.get_mut("rectangle").ok_or(anyhow!("image does not contain 'rectangle'."))?
// after: tolerant migration
match bitmapimage.get_mut("rectangle") {
Some(rect) => convert_transform_to_affine_in_obj(rect)?,
None => log::warn!("bitmapimage.rectangle missing; skipped"),
} Defensive patterns
Strategy: validation
Validate before calling
let img = &comp["value"]["bitmapimage"]["image"];
if img.is_object() && img.get("rectangle").is_none() {
return Err("bitmapimage.image missing 'rectangle'".into());
} Type guard
fn image_has_rectangle(v: &IValue) -> bool {
v.get("bitmapimage")
.and_then(|b| b.get("image"))
.and_then(|i| i.get("rectangle"))
.map_or(false, |r| r.is_object())
} Prevention
- Require image.rectangle in any legacy-file validator.
- Never strip nested fields when transforming rnote JSON.
- Round-trip test old files through the migration in CI.
When it happens
Trigger: Migrating maj0min13 -> maj0min15 with stroke_components[*].value.bitmapimage.image present but missing its 'rectangle' field.
Common situations: Truncated or hand-edited legacy files; older exporter bugs that omitted rectangle; JSON minimizers/transforms that dropped nested fields.
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
- bitmapimage does not contain 'image'.
- bitmapimage does not contain 'rectangle'.
- bitmapimage is not a JSON object.
- image is not a JSON object.
- supplied value is not a JSON object.
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/e52e800a6fb7545c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs:98
.ok_or(anyhow!("vectorimage does not contain 'rectangle'."))?,
)?;
} else if let Some(bitmapimage) = value
.as_object_mut()
.ok_or(anyhow!("value is not a JSON object."))?
.get_mut("bitmapimage")
{
let bitmapimage = bitmapimage
.as_object_mut()
.ok_or(anyhow!("bitmapimage is not a JSON object."))?;
convert_transform_to_affine_in_obj(
bitmapimage
.get_mut("image")
.ok_or(anyhow!("bitmapimage does not contain 'image'."))?
.as_object_mut()
.ok_or(anyhow!("image is not a JSON object."))?
.get_mut("rectangle")
.ok_or(anyhow!("image does not contain 'rectangle'."))?,
)?;
convert_transform_to_affine_in_obj(
bitmapimage
.get_mut("rectangle")
.ok_or(anyhow!("bitmapimage does not contain 'rectangle'."))?,
)?;
}
}
//dbg!(&value);
Ok(Self {
engine_snapshot: value.engine_snapshot,
})
}
}
/// Converts a "object->transform->nalgebra-affine" to "object->(glamx-)affine"View on GitHub (pinned to bbc5354502)