{"record":{"id":"34198d5676f07c68","repo":"BoundaryML/baml","slug":"offset-fits-in-baml-int","errorCode":null,"errorMessage":"offset fits in BAML int","messagePattern":"offset fits in BAML int","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_vm/src/package_baml/time.rs","lineNumber":501,"sourceCode":"                (&full[..open], Some(annotation.to_string()))\n            }\n            _ => (full, None),\n        };\n        let datetime = OffsetDateTime::parse(timestamp, &Rfc3339).map_err(|e| {\n            parse_error(format!(\n                \"ZonedDateTime.parse: cannot parse {timestamp:?} as an RFC 3339 timestamp \\\n                 (zoneless strings belong to PlainDateTime.parse): {e}\"\n            ))\n        })?;\n        let offset_ns = i64::from(datetime.offset().whole_seconds()) * NANOS_PER_SECOND;\n        let (offset_value, iana_value) = match iana {\n            // An IANA annotation wins over the numeric offset; the offset was\n            // still used above to compute the absolute time. The identifier\n            // is validated lazily, on first resolution against the host's\n            // timezone database.\n            Some(iana) => (Value::NULL, Value::object(vm.alloc_string(iana))),\n            None => (\n                Value::try_int(offset_ns).expect(\"offset fits in BAML int\"),\n                Value::NULL,\n            ),\n        };\n        let zoned = copy::time::ZonedDateTime {\n            _nanoseconds: Arc::new(num_bigint::BigInt::from(datetime.unix_timestamp_nanos())),\n            _offset_ns: offset_value,\n            _iana: iana_value,\n        };\n        Ok(zoned.to_value(vm))\n    }\n}\n\nimpl BamlNamespaceTime for PackageBamlImpl {\n    fn _format_zoned(\n        epoch_ns: Arc<num_bigint::BigInt>,\n        offset_ns: i64,\n        iana: Option<&bex_str::BexStr>,\n    ) -> Result<bex_str::BexStr, VmRustFnError> {","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm/src/package_baml/time.rs#L483-L519","documentation":"Internal invariant panic when parsing a ZonedDateTime: the numeric UTC offset (offset_ns) was already validated to be within ±24h (MAX_TZ_OFFSET_NS), so it must fit in a BAML int (i64-backed). Value::try_int().expect() failing means the earlier bound check was bypassed or corrupted.","triggerScenarios":"Parsing a timezone string with an out-of-range custom offset, or internal state corruption causing an unvalidated offset to reach try_int.","commonSituations":"Malformed or hostile timestamp strings with absurd offset components (e.g. '+99999999:00') in date/time data being ingested.","solutions":["Validate/clean offset strings before parsing (offsets within ±23:59).","Report to maintainers if a normal offset string triggers it.","Upgrade the VM build where offset validation covers all parse paths."],"exampleFix":"// before\nlet z = ZonedDateTime.parse(\"2024-01-01T00:00:00+99999999:00\");\n// after\nlet z = ZonedDateTime.parse(\"2024-01-01T00:00:00+05:30\");","handlingStrategy":"validation","validationCode":"// Check the offset portion of a timestamp string is within ±24h before parsing\nfn offset_in_range(ts: &str) -> bool {\n    ts.rsplit_once(['+', '-']).and_then(|(_, o)| o.split(':').next())\n        .and_then(|h| h.parse::<i64>().ok())\n        .map(|h| h.abs() <= 24).unwrap_or(true)\n}","typeGuard":null,"tryCatchPattern":"// Wrap parse in panic boundary when handling untrusted input\nstd::panic::catch_unwind(|| ZonedDateTime_parse(ts)).unwrap_or_else(|_| Err(ParseError::BadOffset))","preventionTips":["Sanitize timestamp strings from untrusted sources before parsing.","Reject offsets beyond ±23:59 at the input boundary.","Keep the VM updated so offset validation covers all parse paths."],"tags":["rust","panic","timezone","parsing","overflow"],"backgroundTag":"value-out-of-range","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}