BoundaryML/baml · error
BAML_CACHE_VERIFY: cached bytecode for key
Error message
BAML_CACHE_VERIFY: cached bytecode for key {} differs from a fresh compile ({} vs {} bytes). This means emit is nondeterministic or a compile input is missing from the cache key — please report this. What it means
Error "BAML_CACHE_VERIFY: cached bytecode for key {} differs from a fresh compile ({} vs {} bytes). This means emit is nondeterministic or a compile input is missing from the cache key — please report this." thrown in BoundaryML/baml.
Solutions
- Do not disable BAML_CACHE_VERIFY while iterating; keep it on so the drift is caught early
- If the error is reproducible, minimize the .baml project that triggers it and report it to the BAML maintainers — a deterministic emit or a complete cache key is required
- For the missing-cache-key case, check whether any compile inputs (env vars, file mtimes, generated files) participate in compilation but are absent from the key computation
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at baml_language/crates/baml_cli/src/bytecode_cache.rs:217 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/cb17be3ea16b1cb9.
Report an issue: GitHub.
Appendix: source
Thrown at baml_language/crates/baml_cli/src/bytecode_cache.rs:217
}
}
pub(crate) fn load(&self) -> Option<Program> {
self.cache.load_shared(&self.key)
}
/// The `BAML_CACHE_VERIFY` tripwire: byte-compare a fresh compile against
/// any existing entry under the same key. A mismatch is a hard error —
/// it means emit is nondeterministic or a compile input is missing from
/// the cache key.
pub(crate) fn verify_against(&self, program: &Program) -> anyhow::Result<()> {
if !Self::verify_enabled() {
return Ok(());
}
if let Some(cached) = self.cache.load_raw(&self.key) {
let fresh = borsh::to_vec(program)?;
if fresh != cached {
anyhow::bail!(
"BAML_CACHE_VERIFY: cached bytecode for key {} differs from a fresh \
compile ({} vs {} bytes). This means emit is nondeterministic or a \
compile input is missing from the cache key — please report this.",
self.key.hex(),
cached.len(),
fresh.len(),
);
}
}
Ok(())
}
/// Write-through after a successful compile. Best-effort: a cache write
/// problem must never fail the run.
pub(crate) fn store(&self, program: &Program) -> std::io::Result<()> {
self.cache.store_shared(&self.key, program)?;
self.cache.maybe_trim();
Ok(())View on GitHub (pinned to bd85ce9dee)