flxzt/rnote · error · anyhow::Error

affine does not have value at index 4

Error message

affine does not have value at index 4

What it means

Index guard in convert_transform_to_affine_in_obj: the affine transform array stored on an object in the file being migrated is shorter than expected, so .get(4) (and similarly 0/1/3) returned None while rebuilding the affine matrix. Fires on .rnote files with truncated or malformed transform arrays.

Solutions

  1. Repair "affine" to contain all 8 elements, e.g. [1,0,0,1,0,0,0,1].
  2. Restore from backup or re-export the document.
  3. Fix the writer to serialize the complete matrix.

Example fix

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

Strategy: validation

Validate before calling

if affine.len() < 8 { return Err("affine matrix incomplete".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 with an "affine" array of length 3 (has 0,1,3 but not 4) during the maj0min15 conversion.

Common situations: Truncated JSON from interrupted writes or a malformed custom exporter.

Related errors


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

Appendix: source

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

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

    Ok(())
}

View on GitHub (pinned to bbc5354502)