flxzt/rnote · error · anyhow::Error

affine does not have value at index 1

Error message

affine does not have value at index 1

What it means

Same migration step as index 81, but the "affine" array had a value at index 0 and none at index 1, so it is missing the second matrix element. The conversion reads indexes 0,1,3,4,6,7 and aborts at the first missing one.

Solutions

  1. Pad or repair the "affine" array to contain all 8 values, e.g. [1,0,0,1,0,0,0,1].
  2. Re-export or restore the file from a backup.
  3. Fix the writer to always emit the full matrix.

Example fix

// before
"affine": [0.5]
// after
"affine": [0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 1.0]
Defensive patterns

Strategy: validation

Validate before calling

if affine.len() < 8 { return Err("affine missing required elements 0,1,3,4,6,7".into()); }

Type guard

fn is_full_affine(a: &serde_json::Value) -> bool {
    a.as_array().map(|a| a.len() >= 8).unwrap_or(false)
}

Prevention

When it happens

Trigger: An .rnote file whose "affine" array has exactly 1 element (or a hole at position 1) when run through the maj0min15 TryFrom conversion.

Common situations: Truncated JSON arrays from a partial write or corrupted serialization.

Related errors


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

Appendix: source

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

        .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)
                .cloned()
                .ok_or(anyhow!("affine does not have value at index 0"))?,
            affine
                .get(1)
                .cloned()
                .ok_or(anyhow!("affine does not have value at index 1"))?,
            affine
                .get(3)
                .cloned()
                .ok_or(anyhow!("affine does not have value at index 3"))?,
            affine
                .get(4)
                .cloned()
                .ok_or(anyhow!("affine does not have value at index 4"))?,
            affine
                .get(6)
                .cloned()
                .ok_or(anyhow!("affine does not have value at index 6"))?,
            affine
                .get(7)
                .cloned()
                .ok_or(anyhow!("affine does not have value at index 7"))?,
        ],
    );

View on GitHub (pinned to bbc5354502)