{"record":{"id":"e52e800a6fb7545c","repo":"flxzt/rnote","slug":"image-does-not-contain-rectangle","errorCode":null,"errorMessage":"image does not contain 'rectangle'.","messagePattern":"image does not contain 'rectangle'\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs","lineNumber":98,"sourceCode":"                        .ok_or(anyhow!(\"vectorimage does not contain 'rectangle'.\"))?,\n                )?;\n            } else if let Some(bitmapimage) = value\n                .as_object_mut()\n                .ok_or(anyhow!(\"value is not a JSON object.\"))?\n                .get_mut(\"bitmapimage\")\n            {\n                let bitmapimage = bitmapimage\n                    .as_object_mut()\n                    .ok_or(anyhow!(\"bitmapimage is not a JSON object.\"))?;\n\n                convert_transform_to_affine_in_obj(\n                    bitmapimage\n                        .get_mut(\"image\")\n                        .ok_or(anyhow!(\"bitmapimage does not contain 'image'.\"))?\n                        .as_object_mut()\n                        .ok_or(anyhow!(\"image is not a JSON object.\"))?\n                        .get_mut(\"rectangle\")\n                        .ok_or(anyhow!(\"image does not contain 'rectangle'.\"))?,\n                )?;\n                convert_transform_to_affine_in_obj(\n                    bitmapimage\n                        .get_mut(\"rectangle\")\n                        .ok_or(anyhow!(\"bitmapimage does not contain 'rectangle'.\"))?,\n                )?;\n            }\n        }\n\n        //dbg!(&value);\n\n        Ok(Self {\n            engine_snapshot: value.engine_snapshot,\n        })\n    }\n}\n\n/// Converts a \"object->transform->nalgebra-affine\" to \"object->(glamx-)affine\"","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs#L80-L116","documentation":"Thrown in TryFrom<RnoteFileMaj0Min13>::try_from when bitmapimage.image is an object but lacks the 'rectangle' key. The migration converts the legacy transform stored under the rectangle into the new affine representation, so the rectangle is mandatory during the maj0min13 -> maj0min15 upgrade.","triggerScenarios":"Migrating maj0min13 -> maj0min15 with stroke_components[*].value.bitmapimage.image present but missing its 'rectangle' field.","commonSituations":"Truncated or hand-edited legacy files; older exporter bugs that omitted rectangle; JSON minimizers/transforms that dropped nested fields.","solutions":["Re-add the 'rectangle' object (with its legacy 'transform') to bitmapimage.image in the file JSON.","Restore the note from a backup and re-save it via the app.","Validate legacy files against the maj0min13 schema before migration to catch missing rectangles early.","Adjust the migration to warn and skip bitmap strokes lacking rectangle instead of aborting the whole file."],"exampleFix":"// before\n.get_mut(\"rectangle\").ok_or(anyhow!(\"image does not contain 'rectangle'.\"))?\n// after: tolerant migration\nmatch bitmapimage.get_mut(\"rectangle\") {\n    Some(rect) => convert_transform_to_affine_in_obj(rect)?,\n    None => log::warn!(\"bitmapimage.rectangle missing; skipped\"),\n}","handlingStrategy":"validation","validationCode":"let img = &comp[\"value\"][\"bitmapimage\"][\"image\"];\nif img.is_object() && img.get(\"rectangle\").is_none() {\n    return Err(\"bitmapimage.image missing 'rectangle'\".into());\n}","typeGuard":"fn image_has_rectangle(v: &IValue) -> bool {\n    v.get(\"bitmapimage\")\n        .and_then(|b| b.get(\"image\"))\n        .and_then(|i| i.get(\"rectangle\"))\n        .map_or(false, |r| r.is_object())\n}","tryCatchPattern":null,"preventionTips":["Require image.rectangle in any legacy-file validator.","Never strip nested fields when transforming rnote JSON.","Round-trip test old files through the migration in CI."],"tags":["json","file-migration","missing-key","schema-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}