flxzt/rnote · error · anyhow::Error

affine does not have value at index 3

Error message

affine does not have value at index 3

What it means

The "affine" array is missing element at index 3 (the second column of the first matrix row in row-major order). convert_transform_to_affine_in_obj skips index 2 (implied 0 in the stored representation) but requires 3, and aborts when absent.

Solutions

  1. Extend "affine" to the full 8-element form [0,1,3,4,6,7 = a,b,c,d,e,f] e.g. [1,0,0,1,0,0,0,1].
  2. Restore the file from backup or regenerate it.
  3. Fix the producing serializer to emit all 8 matrix values.

Example fix

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

Strategy: validation

Validate before calling

for &i in &[0, 1, 3, 4, 6, 7] {
    if affine.get(i).is_none() { return Err(format!("affine missing index {i}")); }
}

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 2-3 (indexes 0,1 present, 3 missing) during the maj0min15 conversion.

Common situations: Partial/truncated file writes, hand edits that removed trailing-but-required elements, or a custom exporter emitting a 3x3's first row only.

Related errors


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

Appendix: source

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

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

    Ok(())
}

View on GitHub (pinned to bbc5354502)