{"record":{"id":"837d16406da47d6d","repo":"BoundaryML/baml","slug":"write-to-string-should-never-fail","errorCode":null,"errorMessage":"write!() to `String` should never fail","messagePattern":"write!\\(\\) to `String` should never fail","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"baml_language/crates/bex_vm/src/package_baml/uint8array.rs","lineNumber":142,"sourceCode":"                    ),\n                })?;\n                let lo = parse_hex_digit(lo).ok_or(VmBamlError::InvalidArgument {\n                    message: format!(\n                        \"uint8array.from_hex: invalid hex digit at position {}\",\n                        i * 2 + 1\n                    ),\n                })?;\n                Ok(hi << 4 | lo)\n            })\n            .collect()\n    }\n\n    fn to_hex(uint8array: &[u8]) -> bex_str::BexStr {\n        use std::fmt::Write;\n        let mut s = String::with_capacity(uint8array.len() * 2);\n        for &b in uint8array {\n            let Ok(()) = write!(s, \"{b:02x}\") else {\n                unreachable!(\"write!() to `String` should never fail\");\n            };\n        }\n        bex_str::BexStr::from(s)\n    }\n\n    fn from_base64(base64_str: &bex_str::BexStr) -> Result<Vec<u8>, VmRustFnError> {\n        use base64::Engine;\n        base64::engine::general_purpose::STANDARD\n            .decode(base64_str.as_str())\n            .map_err(|e| VmBamlError::InvalidArgument {\n                message: format!(\"failed to decode base64: {e}\"),\n            })\n            .map_err(VmRustFnError::BamlError)\n    }\n\n    fn to_base64(uint8array: &[u8]) -> bex_str::BexStr {\n        use base64::Engine;\n        bex_str::BexStr::from(base64::engine::general_purpose::STANDARD.encode(uint8array))","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm/src/package_baml/uint8array.rs#L124-L160","documentation":"Defensive unreachable panic in Uint8Array.to_hex: writing two lowercase hex characters per byte into a String via write!(). Formatted writes into String only fail if the underlying formatter errors, which String's Write impl never does. Hitting this indicates a Rust std-level impossibility.","triggerScenarios":"Not triggerable by user input; only if std::fmt::Write for String somehow errors, which cannot happen in practice.","commonSituations":"Never in production; would only appear if the Rust standard library itself were broken or the code was modified.","solutions":["No user action required; report to maintainers if ever observed.","Check for unusual tooling/patched std builds."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| uint8array_to_hex(bytes)).unwrap_or_else(|_| Err(InternalError))","preventionTips":["No user-side action needed; this path is unreachable by construction.","If ever observed, report a toolchain bug with compiler/std versions."],"tags":["rust","panic","unreachable","hex-encoding"],"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"}