BoundaryML/baml · error
{} uses reserved table `[__baml_codegen]`; remove it because
Error message
{} uses reserved table `[__baml_codegen]`; remove it because `baml generate` owns generated-bytecode metadata. What it means
When embedding the project's baml.toml into generated bytecode, `build_embedded_baml_toml` rejects any baml.toml that defines a `[__baml_codegen]` table, because `baml generate` reserves and owns that table for generated-bytecode metadata. User-authored configs must not use it.
Source
Thrown at baml_language/crates/baml_cli/src/generate.rs:595
reporter.abandon();
crate::reporter::print_error("no files generated (no supported generators found)");
return Ok(crate::ExitCode::Other);
}
reporter.finish("Finished", format!("generated {total_files} file(s)"));
Ok(crate::ExitCode::Success)
}
}
fn build_embedded_baml_toml(project_root: &Path) -> Result<String> {
let path = project_root.join("baml.toml");
let content = std::fs::read_to_string(&path)
.with_context(|| format!("failed to read {}", path.display()))?;
let document = content
.parse::<DocumentMut>()
.with_context(|| format!("failed to parse {}", path.display()))?;
if document.contains_key("__baml_codegen") {
anyhow::bail!(
"{} uses reserved table `[__baml_codegen]`; remove it because `baml generate` owns generated-bytecode metadata.",
path.display()
);
}
let mut embedded = content;
if !embedded.ends_with('\n') {
embedded.push('\n');
}
embedded.push_str(
"\n[__baml_codegen]\nmetadata_version = 1\n\n[__baml_codegen.toolchain]\nversion = ",
);
embedded.push_str(&format!("{:?}", baml_version::CANONICAL_VERSION));
embedded.push('\n');
Ok(embedded)
}
/// Pseudo [`FileId`] for `baml.toml`. The manifest isn't a salsa sourceView on GitHub (pinned to bd85ce9dee)
Solutions
- Remove the `[__baml_codegen]` table (and its keys) from baml.toml
- Re-run `baml generate` so the CLI regenerates its owned metadata
- Keep the source baml.toml out of any flow that copies generated output over it
Example fix
// before (baml.toml) [__baml_codegen] version = 1 // after (baml.toml) # table removed; baml generate owns [__baml_codegen]
Defensive patterns
Strategy: validation
Validate before calling
let doc = std::fs::read_to_string("baml.toml")?.parse::<toml_edit::DocumentMut>()?;
assert!(!doc.contains_key("__baml_codegen"), "remove reserved [__baml_codegen] table from source baml.toml"); Try / catch
match result {
Err(e) if e.to_string().contains("__baml_codegen") => {
eprintln!("Strip the reserved [__baml_codegen] table from baml.toml and regenerate.");
}
other => other?,
} Prevention
- Never check generated baml.toml output back into your source project
- Add a lint/pre-commit check for the __baml_codegen key in source configs
- Keep generated artifacts in ignored output directories
When it happens
Trigger: Running `baml generate` (or tests exercising embedded manifests) against a project whose baml.toml literally contains a `[__baml_codegen]` table, either hand-written or left over from a previous generation flow.
Common situations: A developer copied a generated baml.toml back into source control, or manually edited generated output and reintroduced the reserved table.
Related errors
- script `{target}` has no `--function` and there is no implic
- invalid `[scripts]` in `baml.toml`: {joined}
- test profile `{name}` was requested, but {} does not exist
- test profile `{name}` is not defined in {} (available: {avai
- invalid argument `{token}` in test profile `{name}`: profile
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/809e6495960a9fcf.
Report an issue: GitHub.