{"record":{"id":"1a98f1f8f316d2a3","repo":"flxzt/rnote","slug":"splitorder-try-from-u32-for-value-failed","errorCode":null,"errorMessage":"SplitOrder try_from::<u32>() for value {} failed","messagePattern":"SplitOrder try_from::<u32>\\(\\) for value (.+?) failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-compose/src/splitorder.rs","lineNumber":50,"sourceCode":"impl std::fmt::Display for SplitOrder {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        write!(\n            f,\n            \"{}\",\n            match self {\n                SplitOrder::RowMajor => \"horizontal-first\",\n                SplitOrder::ColumnMajor => \"vertical-first\",\n            }\n        )\n    }\n}\n\nimpl TryFrom<u32> for SplitOrder {\n    type Error = anyhow::Error;\n\n    fn try_from(value: u32) -> Result<Self, Self::Error> {\n        num_traits::FromPrimitive::from_u32(value).ok_or_else(|| {\n            anyhow::anyhow!(\"SplitOrder try_from::<u32>() for value {} failed\", value)\n        })\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":54,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-compose/src/splitorder.rs#L32-L54","documentation":"This error is raised in SplitOrder::try_from (crates/rnote-compose/src/splitorder.rs) when converting a raw u32 into the SplitOrder enum via num_traits::FromPrimitive::from_u32. SplitOrder only has two discriminants (RowMajor=0, ColumnMajor=1), so any value outside 0..=1 fails the generic FromPrimitive lookup and the ok_or_else guard wraps the None into an anyhow error. It typically fires when deserializing a persisted split order or parsing user-supplied numeric input that is out of range or corrupted.","triggerScenarios":"Deserializing or converting an out-of-range u32 (e.g. from a config value or file format field) into SplitOrder, where the value is not one of the enumerated orderings.","commonSituations":"Hand-edited config with an unsupported split-order number; a file written by a newer rnote version using an added variant that this build doesn't know.","solutions":["Set the split order value to a supported number (check the SplitOrder enum variants in crates/rnote-compose/src/splitorder.rs)","Update rnote to a version that knows the newer variant if the value came from a newer file","Sanitize/clamp config values to valid variants before passing them to the engine"],"exampleFix":"// before\n\"split_order\": 7\n// after\n\"split_order\": 0","handlingStrategy":"validation","validationCode":"const SPLIT_ORDER_VARIANTS: u32 = 2; // adjust to the enum's variant count\nif value >= SPLIT_ORDER_VARIANTS {\n    eprintln!(\"split order {} out of range\", value);\n}","typeGuard":"fn is_valid_split_order(v: u32) -> bool {\n    SplitOrder::try_from(v).is_ok()\n}","tryCatchPattern":"match SplitOrder::try_from(value) {\n    Err(e) if e.to_string().contains(\"SplitOrder try_from\") => {\n        eprintln!(\"Unsupported split order value {}; using default\", value);\n        SplitOrder::default()\n    }\n    other => other,\n}","preventionTips":["Only write values produced by the SplitOrder enum, never hand-picked numbers","Regenerate/upgrade config or files when moving between rnote versions","Clamp or map unknown values to a default when loading untrusted data"],"tags":["enum","conversion","validation"],"backgroundTag":"invalid-enum-value","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"}