{"record":{"id":"479435d8077c5258","repo":"BoundaryML/baml","slug":"non-parsable-type-0","errorCode":null,"errorMessage":"Non-parsable type: {0:?}","messagePattern":"Non-parsable type: (.+?)","errorType":"error_code","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_sap/src/sap_model/convert.rs","lineNumber":30,"sourceCode":"\nuse crate::sap_model::{\n    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),","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_sap/src/sap_model/convert.rs#L12-L48","documentation":"ConvertError::NonParsableType is raised while converting BAML types to the SAP model in bex_sap. The named type (class/interface/alias) or leaf type (Uint8Array, Resource, PromptAst, Function, Void, Unknown, Future, TypeVar, AssociatedTypeProjection, Never, RustType, Type) has no SAP-parsable representation. The library pre-computes which names are SAP-parsable in TypeCtx::new and refuses to emit them into the TypeRefDb.","triggerScenarios":"Calling TypeCtx::build_db (directly or via from_sys_op_context) when a class field or type alias references a type where is_sap_parseable fails (e.g. SapTy::Uint8Array, SapTy::Resource, SapTy::Future, SapTy::TypeVar) or a class/alias whose sap_parseable check returned false.","commonSituations":"BAML schemas containing media/resource-backed fields, generic type variables not yet substituted, futures or internal Rust types leaking into a SAP-facing type, or a class referencing another class that itself has an unparsable field.","solutions":["Find the type shown in the error and replace the unparsable leaf (Uint8Array, Resource, Future, TypeVar, etc.) with a SAP-supported type such as string, int, bool, list, or map.","If it is a class reference, check the referenced class's fields — one of them is unparsable and makes the whole reference unparsable; fix or skip that field (fields marked skip are excluded).","If a generic TypeVar is involved, ensure it was substituted with a concrete SAP-parsable type before materializing the parse target (see TypeCtx::normalize_parse_target).","If the type should be SAP-parsable but is not, report it as a possible gap in bex_sap's type coverage."],"exampleFix":"// before (BAML)\nclass Attachment { data: uint8array }\n// after\nclass Attachment { data: string } // base64-encode instead of raw bytes","handlingStrategy":"validation","validationCode":"// Before building the SAP model, ensure no field/alias uses unparsable leaves\nfn validate_sap_parsable(ctx: &TypeCtx) -> Result<(), String> {\n    // TypeCtx already computes this: names with sap_parseable == false are excluded\n    for (name, ok) in &ctx.sap_parseable {\n        if !ok { return Err(format!(\"type {name:?} is not SAP-parsable\")); }\n    }\n    Ok(())\n}","typeGuard":"fn is_sap_parsable_leaf(ty: &SapTy) -> bool {\n    !matches!(ty, SapTy::Uint8Array{..} | SapTy::Resource{..} | SapTy::PromptAst{..} | SapTy::Function{..} | SapTy::Void{..} | SapTy::Unknown{..} | SapTy::Future(..) | SapTy::TypeVar(..) | SapTy::Never{..})\n}","tryCatchPattern":null,"preventionTips":["Keep SAP-facing schemas to primitive, list, map, union, class, and enum types only.","Mark internal fields with skip so the converter excludes them.","Check parseability of each named type after editing schemas."],"tags":["sap","type-conversion","baml","unsupported-type"],"backgroundTag":"unsupported-operation","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"}