flxzt/rnote · error · anyhow::Error

affine does not have value at index 7

Error message

affine does not have value at index 7

What it means

The "affine" array is missing element at index 7 (the final element of the stored matrix). This is the last lookup in convert_transform_to_affine_in_obj, so the array had the previous elements but stopped short of the full 8.

Solutions

  1. Append the missing 8th element so "affine" is a complete [a,b,c,d,e,f,g,h] matrix.
  2. Restore from backup or re-export the document.
  3. Fix the exporter to emit exactly 8 matrix values (use a fixed-size array type so the compiler enforces it).

Example fix

// before
"affine": [1, 0, 0, 1, 10, 20, 0]
// after
"affine": [1, 0, 0, 1, 10, 20, 0, 1]
Defensive patterns

Strategy: validation

Validate before calling

assert_eq!(affine.len(), 8, "affine must have exactly the 8 stored matrix values");

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 with an "affine" array of length 7 (indexes 0-6 present, 7 missing) during the maj0min15 conversion.

Common situations: Off-by-one in a custom exporter (writing 7 of 8 values) or truncated JSON.

Related errors


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

Appendix: source

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

                .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"))?,
        ],
    );

    Ok(())
}

View on GitHub (pinned to bbc5354502)