{"record":{"id":"e72ae2682024e9f0","repo":"BoundaryML/baml","slug":"unexpected-type-for-mime-type-t","errorCode":null,"errorMessage":"unexpected type for mime type: %T","messagePattern":"unexpected type for mime type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_media.go","lineNumber":95,"sourceCode":"}\n\nfunc (m *mediaHolder) pointer() int64 {\n\treturn m.RawObject.Pointer()\n}\n\nfunc (m *mediaHolder) MimeType() (*string, error) {\n\tresult, err := raw_objects.CallMethod(m, \"mime_type\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get mime type: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tas_mime_type, ok := result.(string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for mime type: %T\", result)\n\t}\n\n\treturn &as_mime_type, nil\n}\n\nfunc (m *mediaHolder) IsUrl() (bool, error) {\n\tresult, err := raw_objects.CallMethod(m, \"is_url\", nil)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to get is url: %w\", err)\n\t}\n\n\treturn result.(bool), nil\n}\n\nfunc (m *mediaHolder) IsBase64() (bool, error) {\n\tresult, err := raw_objects.CallMethod(m, \"is_base64\", nil)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to get is base64: %w\", err)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_media.go#L77-L113","documentation":"After calling the runtime's `mime_type` method, the Go wrapper asserts the returned value is a Go string. If the FFI layer deserialized the result into any other Go type, this error is thrown with the actual %T. It indicates the Go client and native runtime disagree on the method's return type — usually an internal contract violation rather than user input.","triggerScenarios":"Calling MimeType() when raw_objects.CallMethod returns a non-nil, non-string value (e.g. []byte, int) due to a serde/FFI type mismatch between the Go client and the Rust runtime.","commonSituations":"Mixed versions of the baml Go module and native library; a runtime change to the mime_type return type not yet reflected in the installed Go client.","solutions":["Pin matching versions of the baml Go module and baml-cli runtime","Update the baml Go dependency to the latest release","Report the %T value shown in the message to the BAML maintainers if versions match"],"exampleFix":"// before (mismatched versions)\nrequire github.com/boundaryml/baml v0.55.0\n// after (aligned)\ngo get github.com/boundaryml/baml@latest && baml-cli --version # ensure runtime matches module","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"mime, err := media.MimeType()\nif err != nil && strings.Contains(err.Error(), \"unexpected type\") {\n    return fmt.Errorf(\"client/runtime version mismatch: %w\", err)\n}","preventionTips":["Pin the Go module and baml-cli to the same release in CI","Re-run baml-cli generate after every dependency upgrade","Treat 'unexpected type' errors as version-skew signals, retry after upgrade"],"tags":["go","ffi","type-mismatch","baml"],"backgroundTag":"type-mismatch","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"}