{"record":{"id":"4ac8c8c5902c3d18","repo":"BigPizzaV3/CodexPlusPlus","slug":"unsupported-dream-skin-backup-schema","errorCode":null,"errorMessage":"unsupported Dream Skin backup schema","messagePattern":"unsupported Dream Skin backup schema","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin.rs","lineNumber":491,"sourceCode":"    theme.insert(\"fonts\", Value::InlineTable(fonts));\n    theme.insert(\"ink\", profile.ink.into());\n    theme.insert(\"opaqueWindows\", profile.opaque_windows.into());\n    theme.insert(\"semanticColors\", Value::InlineTable(semantic_colors));\n    theme.insert(\"surface\", profile.surface.into());\n    theme\n}\n\nfn serialize_item(item: &Item) -> String {\n    let mut document = DocumentMut::new();\n    document[\"value\"] = item.clone();\n    document.to_string()\n}\n\nfn parse_backup_item(backup: &DreamSkinThemeBackup, serialized: &str) -> anyhow::Result<Item> {\n    match backup.schema_version {\n        1 => parse_legacy_item(serialized),\n        BACKUP_SCHEMA_VERSION => parse_document_item(serialized),\n        _ => bail!(\"unsupported Dream Skin backup schema\"),\n    }\n}\n\nfn parse_legacy_item(serialized: &str) -> anyhow::Result<Item> {\n    match format!(\"value = {serialized}\\n\").parse::<DocumentMut>() {\n        Ok(mut document) => document\n            .remove(\"value\")\n            .context(\"serialized Dream Skin backup value is missing\"),\n        Err(_) => parse_legacy_table(serialized),\n    }\n}\n\nfn parse_legacy_table(serialized: &str) -> anyhow::Result<Item> {\n    let document = serialized.parse::<DocumentMut>()?;\n    Ok(Item::Table(document.as_table().clone()))\n}\n\nfn parse_document_item(serialized: &str) -> anyhow::Result<Item> {","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin.rs#L473-L509","documentation":"parse_backup_item deserializes a single backed-up TOML value according to the backup file's schema_version: 1 uses the legacy parser and the current BACKUP_SCHEMA_VERSION uses the document parser. Any other version number hits the catch-all bail!. It is an internal guard: the schema should already have been validated by read_backup, so reaching this arm implies a backup struct was constructed or mutated in code rather than read through read_backup.","triggerScenarios":"Calling restore_base_theme or restore_backup_setting with a DreamSkinThemeBackup whose schema_version is neither 1 nor BACKUP_SCHEMA_VERSION. Since both callers obtain the backup via read_backup (which pre-validates the same versions), this fires only when the struct bypasses read_backup — e.g. a test or new code path builds DreamSkinThemeBackup directly, or a future code path deserializes the JSON without the read_backup gate and a schema bump leaves an older writer.","commonSituations":"Upgrading the library after BACKUP_SCHEMA_VERSION changed while hand-crafted or cached backup structs are reused in-process; writing custom tooling/tests that construct DreamSkinThemeBackup with an invented schema_version; a partially migrated code path that skips read_backup.","solutions":["Ensure every backup is loaded via read_backup (or re-serialize/deserialize it through it) so unsupported versions are rejected before reaching the item parsers.","Regenerate the backup: disable then re-enable the Dream Skin theme against the correct home so a fresh backup with the current BACKUP_SCHEMA_VERSION is written.","If you construct DreamSkinThemeBackup in tests/tools, set schema_version to 1 or the crate's BACKUP_SCHEMA_VERSION constant.","If this fires after a version upgrade, isolate/remove the old backup file and let the library create a new one."],"exampleFix":"// before\nlet backup = DreamSkinThemeBackup { schema_version: 7, .. };\nrestore_backup_setting(desktop, &backup, \"appearanceTheme\")?; // bails\n// after\nlet bytes = std::fs::read(&backup_path)?;\nlet backup: DreamSkinThemeBackup = serde_json::from_slice(&bytes)?;\nassert!(matches!(backup.schema_version, 1 | BACKUP_SCHEMA_VERSION));\nrestore_backup_setting(desktop, &backup, \"appearanceTheme\")?;","handlingStrategy":"type-guard","validationCode":"fn supports_backup(backup: &DreamSkinThemeBackup) -> bool {\n    matches!(backup.schema_version, 1 | BACKUP_SCHEMA_VERSION)\n}","typeGuard":"fn is_supported_schema(v: u32) -> bool {\n    v == 1 || v == BACKUP_SCHEMA_VERSION\n}","tryCatchPattern":"match restore_backup_setting(desktop, &backup, key) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"unsupported Dream Skin backup schema\") => {\n        // backup struct bypassed read_backup; reload via read_backup or regenerate\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always obtain DreamSkinThemeBackup via read_backup, never construct it inline","After a schema bump, migrate or discard old in-process/cached backup structs","Keep schema_version set to the crate constant in tests and tooling"],"tags":["schema","backup","versioning","toml"],"backgroundTag":"schema-validation-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}