{"record":{"id":"536747ef65f6afc5","repo":"BoundaryML/baml","slug":"unknown-type-alias-0","errorCode":null,"errorMessage":"Unknown type alias: {0}","messagePattern":"Unknown type alias: (.+?)","errorType":"error_code","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_sap/src/sap_model/convert.rs","lineNumber":36,"sourceCode":"};\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\nconst MAX_RECURSION_DEPTH: usize = 16;\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_sap/src/sap_model/convert.rs#L18-L54","documentation":"ConvertError::UnknownTypeAlias(DefKey) is raised when flattening a SapTy::TypeAlias reference (convert_ty, get_field_attrs, field_type_is_nullable) and the alias name has no entry in TypeCtx::type_alias_definitions. Aliases must be flattenable to their underlying type.","triggerScenarios":"TypeCtx::build_db or field-attribute derivation encounters a type alias reference (or a class field typed by an alias) whose DefKey is absent from the alias definition map.","commonSituations":"An alias declared in a module not included in the context; a typo in an alias name; an alias removed while other types still reference it; hand-constructed SapTy::TypeAlias values pointing at nonexistent keys.","solutions":["Verify the alias name in the error is declared with a `type X = ...` statement and spelled correctly.","Include the module containing the alias in the compilation context passed to TypeCtx.","Inline the alias's underlying type where the stale reference occurs."],"exampleFix":"// before\ntype UserId = MissingBase\n// after\ntype UserId = int","handlingStrategy":"validation","validationCode":"// Confirm each alias referenced by types resolves in the alias table\nfn alias_exists(ctx: &TypeCtx, key: &DefKey) -> bool {\n    ctx.type_alias_definitions.contains_key(key)\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(ConvertError::UnknownTypeAlias(key)) => eprintln!(\"declare `type {key:?} = ...` or inline its value\"),\n    other => other,\n}","preventionTips":["Declare aliases before or in modules loaded into the context.","Avoid hand-constructing SapTy::TypeAlias values that bypass declaration checks.","Run schema linting to detect dangling alias references."],"tags":["sap","baml","undefined-reference","type-alias"],"backgroundTag":"resource-not-found","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"}