{"record":{"id":"24c5761d8e6d54ea","repo":"BoundaryML/baml","slug":"project-has-errors","errorCode":null,"errorMessage":"Project has errors.","messagePattern":"Project has errors\\.","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/language_server/src/baml_project/mod.rs","lineNumber":169,"sourceCode":"        no_version_check: Option<bool>,\n        feature_flags: &[String],\n    ) -> Result<Vec<GenerateOutput>, anyhow::Error> {\n        let env = std::env::vars().collect();\n        let all_files = self\n            .files\n            .iter()\n            .map(|(document_key, text_document)| {\n                let path_buf = document_key.path();\n                (PathBuf::from(path_buf), text_document.contents.clone())\n            })\n            .collect();\n        let start_time = Instant::now();\n\n        let runtime = self.runtime(env, feature_flags);\n        if let Err(e) = runtime {\n            if e.has_errors() {\n                tracing::error!(\"Failed to run codegen: {:?}\", e);\n                return Err(anyhow::anyhow!(\"Project has errors.\"));\n            } else {\n                tracing::error!(\"Failed to run codegen: {:?}\", e);\n                return Err(e.into());\n            }\n        }\n        let runtime = runtime.unwrap();\n\n        let generated = match runtime.run_codegen(\n            &all_files,\n            no_version_check.unwrap_or(false),\n            GeneratorType::VSCode,\n            false, // strip_tests - not applicable for VSCode extension\n        ) {\n            Ok(gen) => {\n                let elapsed = start_time.elapsed();\n                tracing::debug!(\n                    \"Generated {:?} baml_clients in {:?}ms\",\n                    gen.len(),","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_server/src/baml_project/mod.rs#L151-L187","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before generating, validate BAML sources:\n// baml-cli generate --from baml_src  (inspect diagnostics, exit non-zero on errors)\n// Or use the LSP textDocument/diagnostic results and abort while diagnostics are non-empty","typeGuard":null,"tryCatchPattern":"match baml_project.run_generators_native() {\n    Err(e) if e.to_string().contains(\"Project has errors.\") => {\n        eprintln!(\"BAML source has compile errors; see codegen diagnostics above.\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n    Ok(out) => out,\n}","preventionTips":["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"],"tags":["rust","baml","codegen","project-errors"],"backgroundTag":"schema-validation-failed","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"}