BoundaryML/baml · error · Error
Value ${name} not found.
Error message
Value ${name} not found. What it means
EnumAst.value (viewer API) throws 'Value <name> not found.' when the requested value is not among the enum's registered values. The viewer tracks value names in a Set and fails fast on unknown lookups rather than returning a null viewer.
Source
Thrown at engine/language_client_typescript/typescript_src/type_builder.ts:272
}
type(): FieldType {
return this.bldr.field()
}
}
export class EnumViewer<EnumName extends string, T extends string = string> extends EnumAst<EnumName, T> {
constructor(tb: _TypeBuilder, name: EnumName, values: Set<T | string> = new Set()) {
super(tb, name, values)
}
listValues(): Array<[string, EnumValueViewer]> {
return Array.from(this.values).map((name) => [name, new EnumValueViewer()])
}
value(name: string): EnumValueViewer {
if (!this.values.has(name)) {
throw new Error(`Value ${name} not found.`)
}
return new EnumValueViewer()
}
}
export class EnumValueViewer {
constructor() {}
}
export class EnumBuilder<EnumName extends string, T extends string = string> extends EnumAst<EnumName, T> {
constructor(tb: _TypeBuilder, name: EnumName, values: Set<T | string> = new Set()) {
super(tb, name, values)
}
addValue<S extends string>(name: RestrictNot<EnumName, S, T>): EnumValueBuilder {
if (this.values.has(name)) {
throw new Error(`Value ${name} already exists.`)
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Call listValues() first and verify the exact value name before lookup.
- Fix casing/spelling in the value lookup.
- Register the missing value on the EnumBuilder before inspecting it.
Example fix
// before
const v = enumViewer.value('RED') // throws if absent
// after
const names = enumViewer.listValues().map(([n]) => n)
const v = names.includes('RED') ? enumViewer.value('RED') : null Defensive patterns
Strategy: validation
Validate before calling
const exists = enumViewer.listValues().some(([n]) => n === name)
if (!exists) throw new Error(`enum value '${name}' not registered`) Try / catch
try {
const v = enumViewer.value(name)
} catch (e) {
if (e.message.includes('not found')) return null
throw e
} Prevention
- Call listValues() before dynamic value lookups.
- Match value casing exactly; enums are case-sensitive.
- Register all enum values before inspecting the viewer.
When it happens
Trigger: Calling enumViewer.value('RED') where 'RED' was never added via EnumBuilder value registration, or with mismatched casing (e.g. 'red' vs 'RED').
Common situations: Inspecting a dynamic enum whose values come from a database or config that changed; lookup names sourced from user input.
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
- Property ${name} not found.
- undefined enum: {enum_name}
- Enum '{0}' not found
- Enum {name} not found
- Enum {} does not exist
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b2185732baf12034.
Report an issue: GitHub.