{"record":{"id":"5df1530c1fee5985","repo":"BoundaryML/baml","slug":"unknown-class-0","errorCode":null,"errorMessage":"Unknown class: {0}","messagePattern":"Unknown class: (.+?)","errorType":"error_code","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_sap/src/sap_model/convert.rs","lineNumber":32,"sourceCode":"    self, AnnotatedEnumVariant, AnnotatedField, AnnotatedTy, ArrayTy, AttrLiteral, BigintLiteralTy,\n    BigintTy, BoolLiteralTy, BoolTy, ClassTy, EnumTy, EnumVariantTy, FloatTy, IntLiteralTy, IntTy,\n    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),","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_sap/src/sap_model/convert.rs#L14-L50","documentation":"ConvertError::UnknownClass(DefKey) is declared in the SAP model conversion error enum. It represents a type reference to a class name that cannot be found among the registered class definitions when resolving SAP model types.","triggerScenarios":"Resolving a class-typed reference whose DefKey has no entry in TypeCtx::class_definitions — i.e. the referenced class was never declared or was pruned from the context before build_db.","commonSituations":"A BAML file references a class defined in another module that was not loaded; a typo in a class name; a class removed in a refactor while aliases or fields still reference it.","solutions":["Verify the class name in the error is declared and spelled correctly in your BAML sources.","Ensure the module/file containing the class is included in the compilation context passed to TypeCtx (SysOpContext.class_definitions).","Rebuild/regenerate the SAP model after adding the missing class definition."],"exampleFix":"// before\nfunction Extract() -> MissingClass\n// after\nclass MissingClass { name: string }\nfunction Extract() -> MissingClass","handlingStrategy":"validation","validationCode":"// Verify every referenced class name exists before conversion\nfn class_exists(ctx: &TypeCtx, key: &DefKey) -> bool {\n    ctx.class_definitions.contains_key(key)\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(ConvertError::UnknownClass(key)) => eprintln!(\"declare class {key:?} or fix its spelling\"),\n    other => other,\n}","preventionTips":["Declare every class referenced by function signatures.","Keep class definitions in modules included in the compile context.","Rename classes with editor-wide refactoring, never by hand."],"tags":["sap","baml","undefined-reference","class"],"backgroundTag":"class-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"}