{"record":{"id":"f595decff2a775fb","repo":"BoundaryML/baml","slug":"unknown-media-kind","errorCode":null,"errorMessage":"Unknown media kind","messagePattern":"Unknown media kind","errorType":"error_code","errorClass":"ConvertError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_sap/src/sap_model/convert.rs","lineNumber":26,"sourceCode":"    sync::Arc,\n};\nuse ::sys_types::{ClassDefinition, DefKey, EnumDefinition, SapTy};\nuse indexmap::IndexMap;\n\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\")]","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_sap/src/sap_model/convert.rs#L8-L44","documentation":"`ConvertError::UnknownMediaKind` is raised by the sap_model type converter when it encounters a media kind it does not recognize. During conversion of type expressions containing media (e.g. image/audio/video types), an unrecognized kind string has no mapping in the converter.","triggerScenarios":"Converting a SapTy containing a media variant whose kind (image, audio, etc.) is not one of the kinds `convert.rs` knows — e.g. a newly added media kind in the grammar not yet handled in the converter match.","commonSituations":"Using a new/experimental media type in BLP source with an older bex_sap version; a typo in a media kind name; grammar and converter versions drifting apart.","solutions":["Check the media kind spelling in the source against the kinds supported by your bex_sap version.","Upgrade bex_sap/baml_language so the converter recognizes the new media kind.","Add a match arm for the new media kind in the converter if you maintain the crate.","Fall back to a generic/string type if the media kind is not essential."],"exampleFix":"// before\nmatch kind {\n    MediaKind::Image => ...,\n    MediaKind::Audio => ...,\n}\n// after\nmatch kind {\n    MediaKind::Image => ...,\n    MediaKind::Audio => ...,\n    MediaKind::Video => ..., // newly supported\n    other => return Err(ConvertError::UnknownMediaKind),\n}","handlingStrategy":"type-guard","validationCode":"const SUPPORTED_MEDIA_KINDS: &[&str] = &[\"image\", \"audio\", \"video\"];\nfn media_kind_supported(k: &str) -> bool { SUPPORTED_MEDIA_KINDS.contains(&k) }\n// check before conversion","typeGuard":"fn as_known_media_kind(k: &MediaKind) -> Option<&MediaKind> {\n    matches!(k, MediaKind::Image | MediaKind::Audio | MediaKind::Video).then_some(k)\n}","tryCatchPattern":"match convert(ty) {\n    Ok(m) => m,\n    Err(ConvertError::UnknownMediaKind) => { eprintln!(\"media kind unsupported by this bex_sap version\"); fallback_to_string_type(ty) }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Upgrade bex_sap when using newly added media kinds.","Validate media kind names against the supported list before conversion.","Keep grammar and converter match arms in sync in CI."],"tags":["rust","type-conversion","enum"],"backgroundTag":"unsupported-enum-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}