BoundaryML/baml · error
Enum {} does not exist
Error message
Enum {} does not exist What it means
Thrown by find_enum_value in the BAML runtime's output-format renderer when an enum referenced in a prompt/output schema neither exists in the IR nor has a runtime override. The renderer walks the intermediate representation (IR) to render enums for the LLM output contract; if the enum walker errored (enum not in the schema) and no RuntimeEnumOverride was supplied, it bails immediately.
Source
Thrown at engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:180
}
let name = Name::new_with_alias(field_name.to_string(), alias.value());
let desc = desc.value();
let r#type = field_walker.r#type();
let needed = needed.value().unwrap_or(false);
Ok(Some((name, r#type.clone(), desc, needed)))
}
fn find_enum_value(
enum_name: &str,
value_name: &str,
enum_walker: &Result<EnumWalker<'_>>,
overrides: &Option<&RuntimeEnumOverride>,
ctx: &RuntimeContext,
) -> Result<Option<(Name, Option<String>)>> {
if enum_walker.is_err() && overrides.is_none() {
anyhow::bail!("Enum {} does not exist", enum_name);
}
let value_walker = match enum_walker {
Ok(e) => e.find_value(value_name),
Err(_) => None,
};
let value_overrides = overrides.map(|o| o.values.get(value_name)).flatten();
if value_overrides.is_none() && value_walker.is_none() {
anyhow::bail!("Enum {} does not have a value: {}", enum_name, value_name);
}
let mut skip = OverridableValue::Unset;
let mut alias = OverridableValue::Unset;
let mut desc = OverridableValue::Unset;
if let Some(attrs) = value_overrides {
match attrs.skip {View on GitHub (pinned to bd85ce9dee)
Solutions
- Check the enum name referenced by the response model for typos and confirm it is defined in a .baml file included in the project.
- If the enum is intentionally dynamic (test/eval overrides), pass a RuntimeEnumOverride containing that enum in the RuntimeContext.
- Re-run baml-cli generate / refresh the runtime so the IR includes newly added enums.
- If the enum was renamed, update all classes/enums referencing the old name.
Example fix
// before (baml)
class Output {
category Category // Category not defined
}
// after
enum Category { A B }
class Output {
category Category
} Defensive patterns
Strategy: validation
Validate before calling
// before rendering, confirm every enum type used in output schema exists
// (pseudo: iterate schema fields, check runtime.ir().find_enum(name).is_ok())
if runtime.ir().find_enum("Category").is_err() && override_for("Category").is_none() {
panic!("Enum Category missing from schema and overrides");
} Type guard
fn enum_exists(runtime: &BamlRuntime, name: &str) -> bool {
runtime.ir().find_enum(name).is_ok()
} Prevention
- Run baml-cli generate in CI to surface schema reference errors early.
- Keep all enum definitions inside baml_src and never reference names by hand.
- When using dynamic overrides, always register overrides for every referenced enum.
When it happens
Trigger: Rendering output format for a response model whose field type references an enum name not present in any BAML schema file, and no RuntimeEnumOverride was passed via RuntimeContext (e.g. test-case or client overrides).
Common situations: Typo in the enum name in a class field; enum defined in a file not included in the BAML source set; renaming/deleting an enum while tests or clients still reference it; relying on dynamic overrides but forgetting to provide them.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Enum {} does not have a value: {}
- Enum {} not found
- Schema inconsistency: {message}
- Unknown enum: {0}
- Enum '{0}' not found
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/90e5cb908136b93c.
Report an issue: GitHub.