{"record":{"id":"efae56c137c05253","repo":"flxzt/rnote","slug":"bitmapimage-is-not-a-json-object","errorCode":null,"errorMessage":"bitmapimage is not a JSON object.","messagePattern":"bitmapimage is not a JSON object\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs","lineNumber":89,"sourceCode":"                .as_object_mut()\n                .ok_or(anyhow!(\"value is not a JSON object.\"))?\n                .get_mut(\"vectorimage\")\n            {\n                convert_transform_to_affine_in_obj(\n                    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","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/fileformats/rnoteformat/maj0min15.rs#L71-L107","documentation":"Thrown in TryFrom<RnoteFileMaj0Min13>::try_from when a stroke component's value contains the key 'bitmapimage' but the bound value itself is not a JSON object (e.g. a string, number or array). The migration needs to mutate bitmapimage fields to convert transform matrices, so it requires an object and returns this error otherwise.","triggerScenarios":"Migrating maj0min13 -> maj0min15 where stroke_components[*].value.bitmapimage is a non-object JSON value while the key 'bitmapimage' exists.","commonSituations":"Corrupted or hand-edited legacy .rnote files; files written by third-party exporters that emit scalar/array payloads under 'bitmapimage'.","solutions":["Open the file JSON and restore 'bitmapimage' to a proper object containing 'image' and 'rectangle' keys.","Recover from a backup or re-save the note from a version that reads the file correctly.","Fix any file-generating tooling to serialize bitmapimage as a struct/object, not a primitive.","Soften the migration to skip invalid bitmapimage entries with a warning instead of erroring."],"exampleFix":"// before\nlet bitmapimage = bitmapimage.as_object_mut().ok_or(anyhow!(\"bitmapimage is not a JSON object.\"))?;\n// after (caller-side validation before migration)\nif !comp_value[\"bitmapimage\"].is_object() {\n    return Err(anyhow!(\"corrupt file: bitmapimage must be an object\"));\n}","handlingStrategy":"validation","validationCode":"let bi = &comp[\"value\"][\"bitmapimage\"];\nif !bi.is_object() {\n    return Err(\"bitmapimage must be a JSON object\".into());\n}","typeGuard":"fn is_bitmapimage(v: &IValue) -> bool {\n    v.get(\"bitmapimage\").map_or(false, |b| b.is_object())\n}","tryCatchPattern":"match RnoteFileMaj0Min15::try_from(file_maj0min13) {\n    Ok(f) => f,\n    Err(e) if e.to_string().contains(\"bitmapimage is not a JSON object\") => {\n        // restore from backup or surface a 'corrupt file' dialog\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify bitmapimage nodes are objects before running the migration.","Do not post-process rnote JSON with tools that may stringify objects.","Keep a pre-migration copy of the file for recovery."],"tags":["json","file-migration","bitmapimage","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"}