flxzt/rnote · error · anyhow::Error

vectorimage does not contain 'rectangle'.

Error message

vectorimage does not contain 'rectangle'.

What it means

Thrown in TryFrom::<RnoteFileMaj0Min13>::try_from during the maj0min13->maj0min15 migration. A vectorimage payload must contain a 'rectangle' entry whose transform is converted to a glam affine; when the key is missing, migration aborts. This means the vector-image stroke data does not conform to the v0.13 schema the migrator expects.

Solutions

  1. Add a 'rectangle' object (with the 'transform' payload) to the vectorimage entry.
  2. Re-save the file with the originating Rnote version so the schema matches, then retry.
  3. Restore the file from a backup or Rnote's autosave.
  4. If the component is unusable, set its 'value' to null so migration skips it.

Example fix

// before
{"vectorimage": {"path": "..."}}
// after
{"vectorimage": {"path": "...", "rectangle": {"transform": {"affine": [1,0,0,1,0,0,0,0,1]}}}}
Defensive patterns

Strategy: validation

Validate before calling

fn vectorimage_has_rectangle(comp: &serde_json::Value) -> bool {
    comp.get("value")
        .and_then(|v| v.get("vectorimage"))
        .and_then(|vi| vi.get("rectangle"))
        .is_some()
}

Type guard

fn get_rectangle<'a>(vectorimage: &'a serde_json::Value) -> Option<&'a serde_json::Map<String, serde_json::Value>> {
    vectorimage.get("rectangle").and_then(|r| r.as_object())
}

Try / catch

match RnoteFileMaj0Min15::try_from(file) {
    Ok(f) => open(f),
    Err(e) if e.to_string().contains("does not contain 'rectangle'") => {
        log::error!("vectorimage missing rectangle geometry: {e}");
        offer_backup_restore_or_repair();
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: try_from hits a component where value['vectorimage'] is an object but has no 'rectangle' key (renamed, dropped, or replaced by another geometry key).

Common situations: Files edited by hand or third-party tools that removed/renamed 'rectangle', or archives corrupted by partial writes.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/47d90bd91ac8d47c. Report an issue: GitHub.

Appendix: source

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

                    convert_transform_to_affine_in_obj(ellipse)?;
                }
            } else if let Some(textstroke) = value
                .as_object_mut()
                .ok_or(anyhow!("value is not a JSON object."))?
                .get_mut("textstroke")
            {
                convert_transform_to_affine_in_obj(textstroke)?;
            } else if let Some(vectorimage) = value
                .as_object_mut()
                .ok_or(anyhow!("value is not a JSON object."))?
                .get_mut("vectorimage")
            {
                convert_transform_to_affine_in_obj(
                    vectorimage
                        .as_object_mut()
                        .ok_or(anyhow!("vectorimage is not a JSON object."))?
                        .get_mut("rectangle")
                        .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'."))?,

View on GitHub (pinned to bbc5354502)