flxzt/rnote · error · anyhow::Error

bitmapimage does not contain 'rectangle'.

Error message

bitmapimage does not contain 'rectangle'.

What it means

Thrown in TryFrom<RnoteFileMaj0Min13>::try_from when a bitmapimage stroke object lacks the top-level 'rectangle' key. After converting image.rectangle, the migration also converts bitmapimage.rectangle itself to the new affine format; a missing rectangle fails the maj0min13 -> maj0min15 upgrade.

Solutions

  1. Restore the 'rectangle' object on bitmapimage in the file JSON, including its legacy 'transform'.
  2. Recover the note from a backup and re-save it through the app.
  3. Pre-validate the file with the maj0min13 schema (require bitmapimage.rectangle) before migrating.
  4. Patch the migration to skip bitmap strokes without rectangle with a warning.

Example fix

// before
.ok_or(anyhow!("bitmapimage does not contain 'rectangle'."))?
// after
if let Some(rect) = bitmapimage.get_mut("rectangle") {
    convert_transform_to_affine_in_obj(rect)?;
} else {
    log::warn!("bitmapimage.rectangle missing; skipped");
}
Defensive patterns

Strategy: validation

Validate before calling

let bi = &comp["value"]["bitmapimage"];
if bi.is_object() && bi.get("rectangle").is_none() {
    return Err("bitmapimage missing 'rectangle'".into());
}

Type guard

fn bitmapimage_has_rectangle(v: &IValue) -> bool {
    v.get("bitmapimage")
        .and_then(|b| b.get("rectangle"))
        .map_or(false, |r| r.is_object())
}

Prevention

When it happens

Trigger: Migrating maj0min13 -> maj0min15 with stroke_components[*].value.bitmapimage missing its 'rectangle' field.

Common situations: Hand-edited or truncated legacy .rnote files; third-party exporters that omit the rectangle placement metadata.

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

Appendix: source

Thrown at crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs:103

                .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"
fn convert_transform_to_affine_in_obj(obj: &mut IValue) -> anyhow::Result<()> {
    let obj = obj
        .as_object_mut()
        .ok_or(anyhow!("supplied value is not a JSON object."))?;
    let transform = obj

View on GitHub (pinned to bbc5354502)