{"record":{"id":"f17fd9b1de3dc5c2","repo":"BoundaryML/baml","slug":"unknown-enum-0","errorCode":null,"errorMessage":"Unknown enum: {0}","messagePattern":"Unknown enum: (.+?)","errorType":"error_code","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_sap/src/sap_model/convert.rs","lineNumber":34,"sourceCode":"    MapTy, MediaTy, NullTy, StringLiteralTy, StringTy, TyResolved, TyWithMeta, TypeAnnotations,\n    TypeRefDb, UnionTy,\n};\n\nimpl crate::sap_model::TypeIdent for DefKey {}\n\n#[derive(thiserror::Error, Debug)]\npub enum ConvertError {\n    #[error(\"Failed to parse float: {0}\")]\n    ParseFloat(#[from] std::num::ParseFloatError),\n    #[error(\"Unknown media kind\")]\n    UnknownMediaKind,\n    #[error(\"Float literals cannot be parsed\")]\n    FloatLiteral,\n    #[error(\"Non-parsable type: {0:?}\")]\n    NonParsableType(Box<SapTy>),\n    #[error(\"Unknown class: {0}\")]\n    UnknownClass(DefKey),\n    #[error(\"Unknown enum: {0}\")]\n    UnknownEnum(DefKey),\n    #[error(\"Unknown type alias: {0}\")]\n    UnknownTypeAlias(DefKey),\n    #[error(\"Unknown name (could not determine if it was a class, enum, or type alias): {0}\")]\n    UnknownName(DefKey),\n    #[error(\"Could not add a type to the database as the name `{0}` is already present\")]\n    AlreadyPresent(DefKey),\n    #[error(\"Recursion depth exceeded for {0}\")]\n    RecursionDepthExceeded(&'static str),\n    #[error(\"Unions must be flattened\")]\n    UnflattenedUnion,\n    /// Something like `type A = B; type B = A;` is invalid.\n    #[error(\"Recursive type alias without indirection: {0}\")]\n    DirectRecursiveTypeAlias(DefKey),\n    #[error(\"Internal error (please report): {0}\")]\n    InternalError(&'static str),\n}\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_sap/src/sap_model/convert.rs#L16-L52","documentation":"ConvertError::UnknownEnum(DefKey) is raised in convert_ty when a SapTy::EnumVariant reference names an enum that has no entry in TypeCtx::enum_definitions. The library cannot resolve the enum variant without its EnumDefinition.","triggerScenarios":"Converting a type like EnumVariant(MyEnum, SomeVariant) via TypeCtx::build_db / convert_ty when MyEnum was never declared or not loaded into the context.","commonSituations":"A field references an enum variant of an enum defined in an unloaded module; a typo in the enum name; an enum deleted during refactoring while a function return type still uses it.","solutions":["Check that the enum named in the error is declared and spelled correctly.","Ensure the enum's defining module is included in the compilation context (SysOpContext.enum_definitions).","Replace the stale enum reference with an existing enum or a plain string type."],"exampleFix":"// before\nfunction Pick() -> Status.Active // Status not defined\n// after\nenum Status { Active Completed }\nfunction Pick() -> Status.Active","handlingStrategy":"validation","validationCode":"// Ensure every enum referenced by a variant type is declared\nfn enum_exists(ctx: &TypeCtx, key: &DefKey) -> bool {\n    ctx.enum_definitions.contains_key(key)\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(ConvertError::UnknownEnum(key)) => eprintln!(\"declare enum {key:?} before using its variants\"),\n    other => other,\n}","preventionTips":["Declare enums in the same or an imported module before referencing their variants.","Use static checks/linting to catch dangling enum references.","Grep for variant usages before deleting an enum."],"tags":["sap","baml","undefined-reference","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}