{"record":{"id":"a15210570ec13822","repo":"flxzt/rnote","slug":"bitmapimage-does-not-contain-image","errorCode":null,"errorMessage":"bitmapimage does not contain 'image'.","messagePattern":"bitmapimage does not contain 'image'\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs","lineNumber":94,"sourceCode":"                    vectorimage\n                        .as_object_mut()\n                        .ok_or(anyhow!(\"vectorimage is not a JSON object.\"))?\n                        .get_mut(\"rectangle\")\n                        .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        })","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs#L76-L112","documentation":"Thrown in TryFrom<RnoteFileMaj0Min13>::try_from when the migration processes a bitmapimage stroke whose object lacks the required 'image' key. The migration must descend into bitmapimage.image.rectangle to convert the legacy transform into an affine matrix, so a missing 'image' key aborts the file upgrade.","triggerScenarios":"Migrating maj0min13 -> maj0min15 with stroke_components[*].value.bitmapimage present but no 'image' field inside it.","commonSituations":"Partially written or truncated legacy files; hand-edited JSON where 'image' was removed; exporters from other tools that omit nested image metadata.","solutions":["Reconstruct the missing 'image' object (with its 'rectangle') in the file JSON from a backup or by re-inserting the bitmap image in the app.","Restore the note from an earlier backup and re-save it through the app.","Validate the legacy file against the maj0min13 bitmapimage schema before attempting the migration.","Patch the migration to report which component index is malformed and skip it rather than failing the whole file."],"exampleFix":"// before: hard failure on missing key\n.ok_or(anyhow!(\"bitmapimage does not contain 'image'.\"))?\n// after: defensive skip in migration\nlet Some(image) = bitmapimage.get_mut(\"image\") else {\n    log::warn!(\"bitmapimage missing 'image'; skipping transform conversion\");\n    return Ok(());\n};","handlingStrategy":"validation","validationCode":"let bi = &comp[\"value\"][\"bitmapimage\"];\nif bi.is_object() && bi.get(\"image\").is_none() {\n    return Err(\"bitmapimage missing 'image'\".into());\n}","typeGuard":"fn has_image(v: &IValue) -> bool {\n    v.get(\"bitmapimage\").map_or(false, |b| b.get(\"image\").is_some())\n}","tryCatchPattern":"if let Err(e) = migrate(file) {\n    if e.to_string().contains(\"does not contain 'image'\") {\n        // offer backup restore / re-insert image in app\n    }\n}","preventionTips":["Check bitmapimage.image exists before migrating.","Avoid truncating JSON when editing files externally.","Test migrations on copies of real legacy files."],"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"}