{"record":{"id":"42fd397ea72d891a","repo":"BoundaryML/baml","slug":"minute-fits-in-u8","errorCode":null,"errorMessage":"minute fits in u8","messagePattern":"minute fits in u8","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_vm/src/package_baml/time.rs","lineNumber":435,"sourceCode":"        })?;\n        let time_ns = i64::from(parsed.hour()) * NANOS_PER_HOUR\n            + i64::from(parsed.minute()) * NANOS_PER_MINUTE\n            + i64::from(parsed.second()) * NANOS_PER_SECOND\n            + i64::from(parsed.nanosecond());\n        Ok(copy::time::PlainTime {\n            _nanoseconds: time_ns,\n        }\n        .to_value(vm))\n    }\n\n    fn _to_string_impl(plaintime: &view::time::PlainTime<'_>) -> bex_str::BexStr {\n        // Normalize manually-constructed out-of-range values into [0, 24h).\n        let ns = plaintime._nanoseconds().rem_euclid(MAX_TZ_OFFSET_NS);\n        let mut out = String::new();\n        format_clock_into(\n            &mut out,\n            u8::try_from(ns / NANOS_PER_HOUR).expect(\"hour fits in u8\"),\n            u8::try_from(ns / NANOS_PER_MINUTE % 60).expect(\"minute fits in u8\"),\n            u8::try_from(ns / NANOS_PER_SECOND % 60).expect(\"second fits in u8\"),\n            u32::try_from(ns % NANOS_PER_SECOND).expect(\"subsecond fits in u32\"),\n        );\n        bex_str::BexStr::from(out)\n    }\n}\n\n#[allow(clippy::used_underscore_items)] // Autogenerated from private BAML fields\nimpl BamlClassTimeTimeZoneOffset for PackageBamlImpl {\n    fn from_duration(vm: &mut BexVm, duration: &Value) -> Result<Value, VmRustFnError> {\n        let nanos = {\n            let instance = vm\n                .as_instance(duration)\n                .expect(\"TimeZoneOffset.from_duration: expected Duration instance\");\n            view::time::Duration { instance }._nanoseconds()\n        };\n        let offset_ns = i64::try_from(&*nanos)\n            .ok()","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm/src/package_baml/time.rs#L417-L453","documentation":"Internal invariant panic during PlainTime string formatting: the minute bucket ns / NANOS_PER_MINUTE % 60 must be 0..59 and therefore fit in u8. The expect() failing indicates broken arithmetic/constants, since the modulo bounds the value by construction.","triggerScenarios":"Unreachable with correct code; triggered only if MAX_TZ_OFFSET_NS or NANOS_PER_* constants are inconsistent or the nanosecond value is corrupt.","commonSituations":"VM development, constant refactors, or corrupted internal state.","solutions":["Report to maintainers with the failing value.","Rebuild the crate so constants are consistent.","Avoid touching private _nanoseconds fields directly."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn plain_time_in_range(ns: i64) -> bool { (0..86_400_000_000_000).contains(&ns) }","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| plaintime_to_string(pt)).unwrap_or_else(|_| Err(FormatError::Internal))","preventionTips":["Use public constructors only.","Avoid direct private-field construction.","Report any reproduction to maintainers."],"tags":["rust","panic","internal-invariant","datetime-formatting"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}