{"record":{"id":"c3cdd61dfe848241","repo":"flxzt/rnote","slug":"image-is-not-a-json-object","errorCode":null,"errorMessage":"image is not a JSON object.","messagePattern":"image is not a JSON object\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs","lineNumber":96,"sourceCode":"                        .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        })\n    }\n}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs#L78-L114","documentation":"Thrown in TryFrom<RnoteFileMaj0Min13>::try_from when bitmapimage.image exists but is not a JSON object. The migration chains .as_object_mut() to reach image.rectangle for the transform-to-affine conversion; a non-object 'image' (string/array/number) makes that impossible and aborts the upgrade.","triggerScenarios":"Migrating maj0min13 -> maj0min15 where stroke_components[*].value.bitmapimage.image is a non-object JSON value.","commonSituations":"Corrupted legacy files; files hand-edited so 'image' holds a scalar or array; buggy third-party rnote generators.","solutions":["Fix the file JSON so bitmapimage.image is an object containing 'rectangle'.","Restore from a backup and re-save the note in the app.","Correct the generating/exporting tool to serialize image as an object.","Make the migration tolerant: skip components whose image is malformed and collect a report instead of failing."],"exampleFix":"// before\n.as_object_mut().ok_or(anyhow!(\"image is not a JSON object.\"))?\n// after: validate shape first\nif !bitmapimage[\"image\"].is_object() {\n    anyhow::bail!(\"malformed legacy file: bitmapimage.image must be an object\");\n}","handlingStrategy":"type-guard","validationCode":"let img = &comp[\"value\"][\"bitmapimage\"][\"image\"];\nif !img.is_object() {\n    return Err(\"bitmapimage.image must be an object\".into());\n}","typeGuard":"fn image_is_object(v: &IValue) -> bool {\n    v.get(\"bitmapimage\")\n        .and_then(|b| b.get(\"image\"))\n        .map_or(false, |i| i.is_object())\n}","tryCatchPattern":null,"preventionTips":["Serialize bitmapimage.image with serde structs, not raw values.","Reject third-party files failing a schema check before opening.","Keep note backups before app upgrades."],"tags":["json","file-migration","type-mismatch","schema-validation"],"backgroundTag":"schema-validation-failed","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"}