flxzt/rnote · error · anyhow::Error

supplied value is not a JSON object.

Error message

supplied value is not a JSON object.

What it means

Thrown at the top of convert_transform_to_affine_in_obj, called from TryFrom<RnoteFileMaj0Min13>::try_from during the maj0min13 -> maj0min15 migration. The helper expects the value passed in (e.g. vectorimage.rectangle or textstroke) to be a JSON object holding a 'transform' key; a non-object value cannot be mutated and triggers this error.

Solutions

  1. Fix the file JSON so the node passed to the converter is an object with a 'transform' key.
  2. Restore the note from a backup and re-save it in the app.
  3. Add an is_object() check before calling convert_transform_to_affine_in_obj and skip/handle non-objects.
  4. Fix any tooling that generates these nodes to serialize them as objects.

Example fix

// before: assumes obj shape
convert_transform_to_affine_in_obj(rect)?;
// after: guard first
if !rect.is_object() {
    anyhow::bail!("rectangle node is not an object; file may be corrupt");
}
convert_transform_to_affine_in_obj(rect)?;
Defensive patterns

Strategy: type-guard

Validate before calling

if !node.is_object() {
    return Err("transform-bearing node must be an object".into());
}

Type guard

fn is_object(v: &IValue) -> bool { v.is_object() }

Try / catch

match convert_transform_to_affine_in_obj(node) {
    Ok(()) => {},
    Err(e) if e.to_string().contains("supplied value is not a JSON object") => {
        // treat file as corrupt; restore backup
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Passing a non-object IValue (string, number, array, bool) as the rect/shape/textstroke node into convert_transform_to_affine_in_obj during file migration.

Common situations: Legacy .rnote files whose rectangle/textstroke nodes are scalars or arrays due to corruption, hand edits, or non-conforming exporters.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

                        .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
        .remove("transform")
        .ok_or(anyhow!("rect does not contain 'transform'."))?;
    let transform = transform
        .as_object()
        .ok_or(anyhow!("transform is not a JSON object."))?;
    let affine = transform
        .get("affine")
        .ok_or(anyhow!("transform does not contain 'affine'."))?
        .as_array()
        .ok_or(anyhow!("affine not an array."))?;

    obj.insert(
        "affine",
        vec![
            #[allow(clippy::get_first)]
            affine
                .get(0)

View on GitHub (pinned to bbc5354502)