flxzt/rnote · error · anyhow::Error

vectorimage is not a JSON object.

Error message

vectorimage is not a JSON object.

What it means

Thrown in TryFrom::<RnoteFileMaj0Min13>::try_from during the maj0min13->maj0min15 migration. When a component's 'value' contains a 'vectorimage' key, that payload must be a JSON object so its 'rectangle' (whose transform is converted to an affine) can be accessed; a non-object vectorimage aborts migration. This indicates malformed vector-image stroke data.

Solutions

  1. Make 'vectorimage' an object containing a 'rectangle' entry with the transform.
  2. Re-save the file with the Rnote version that wrote it, then retry migration.
  3. Restore the file from a backup or autosave.
  4. Null the component's 'value' if unrecoverable so the migration skips it.

Example fix

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

Strategy: validation

Validate before calling

fn vectorimage_is_object(comp: &serde_json::Value) -> bool {
    comp.get("value")
        .and_then(|v| v.get("vectorimage"))
        .map_or(true, |vi| vi.is_object())
}

Type guard

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

Try / catch

match RnoteFileMaj0Min15::try_from(file) {
    Ok(f) => open(f),
    Err(e) if e.to_string().contains("vectorimage is not a JSON object") => {
        log::error!("malformed vectorimage payload: {e}");
        restore_from_backup();
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: try_from hits a component where value['vectorimage'] exists but is not a JSON object, e.g. vectorimage: "data" or vectorimage: [].

Common situations: Hand-edited .rnote archives, corrupted files from interrupted writes, or output from an incompatible exporter that serialized vectorimage as a non-object.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

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

                    .get_mut("ellipse")
                {
                    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."))?

View on GitHub (pinned to bbc5354502)