BoundaryML/baml · error · anyhow::Error
Project has errors.
Error message
Project has errors.
What it means
BamlProject.run_generators_native throws "Project has errors." when building the runtime produced an error collection that has_errors(), meaning the BAML source currently fails to compile/generate. Instead of returning the detailed errors, the generator path deliberately collapses them into this generic message (details are logged via tracing::error!). Fix the underlying BAML errors first.
Source
Thrown at engine/language_server/src/baml_project/mod.rs:169
no_version_check: Option<bool>,
feature_flags: &[String],
) -> Result<Vec<GenerateOutput>, anyhow::Error> {
let env = std::env::vars().collect();
let all_files = self
.files
.iter()
.map(|(document_key, text_document)| {
let path_buf = document_key.path();
(PathBuf::from(path_buf), text_document.contents.clone())
})
.collect();
let start_time = Instant::now();
let runtime = self.runtime(env, feature_flags);
if let Err(e) = runtime {
if e.has_errors() {
tracing::error!("Failed to run codegen: {:?}", e);
return Err(anyhow::anyhow!("Project has errors."));
} else {
tracing::error!("Failed to run codegen: {:?}", e);
return Err(e.into());
}
}
let runtime = runtime.unwrap();
let generated = match runtime.run_codegen(
&all_files,
no_version_check.unwrap_or(false),
GeneratorType::VSCode,
false, // strip_tests - not applicable for VSCode extension
) {
Ok(gen) => {
let elapsed = start_time.elapsed();
tracing::debug!(
"Generated {:?} baml_clients in {:?}ms",
gen.len(),View on GitHub (pinned to bd85ce9dee)
Solutions
- Check the tracing/terminal output above the error for the detailed "Failed to run codegen" diagnostics listing the actual BAML errors
- Open the BAML files in the editor (or run the language server diagnostics) and fix the reported syntax/type errors
- Run baml-cli generate locally or use the BAML VS Code extension to see per-file errors
- Revert the most recent .baml changes to isolate which edit broke codegen
Defensive patterns
Strategy: try-catch
Validate before calling
// Before generating, validate BAML sources: // baml-cli generate --from baml_src (inspect diagnostics, exit non-zero on errors) // Or use the LSP textDocument/diagnostic results and abort while diagnostics are non-empty
Try / catch
match baml_project.run_generators_native() {
Err(e) if e.to_string().contains("Project has errors.") => {
eprintln!("BAML source has compile errors; see codegen diagnostics above.");
std::process::exit(1);
}
Err(e) => return Err(e),
Ok(out) => out,
} Prevention
- Run baml-cli generate or the VS Code extension diagnostics before committing BAML changes
- Add a CI step that fails the build when BAML codegen reports errors
- Keep detailed tracing output enabled to see the underlying error list behind this generic message
When it happens
Trigger: Running baml-cli generate (or the LSP's generator flow) while any .baml file in the project has syntax errors, type errors, invalid configuration, or semantic validation failures that make BamlRuntime construction return Err with has_errors() == true.
Common situations: A recently edited .baml file broke the schema; a partially applied refactor left invalid function/enum definitions; generated clients are being run in CI while the checked-in BAML source is stale or broken.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- BAML Generate failed - Project has errors.
- {0}
- interned member `{name}` cannot be another member's child
- the master member cannot be interned: the master is the plai
- {message}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/24c5761d8e6d54ea.
Report an issue: GitHub.