{"record":{"id":"78a6b95d7d86766d","repo":"BoundaryML/baml","slug":"unexpected-type-for-as-url-t","errorCode":null,"errorMessage":"unexpected type for as_url: %T","messagePattern":"unexpected type for as_url: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_media.go","lineNumber":131,"sourceCode":"\t\treturn false, fmt.Errorf(\"failed to get is base64: %w\", err)\n\t}\n\n\treturn result.(bool), nil\n}\n\nfunc (m *mediaHolder) AsUrl() (*string, error) {\n\tresult, err := raw_objects.CallMethod(m, \"as_url\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get as url: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tas_url, ok := result.(string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for as_url: %T\", result)\n\t}\n\n\treturn &as_url, nil\n}\nfunc (m *mediaHolder) AsBase64() (*string, error) {\n\tresult, err := raw_objects.CallMethod(m, \"as_base64\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get as base64: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tas_base64, ok := result.(string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for as_base64: %T\", result)\n\t}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_media.go#L113-L149","documentation":"After the `as_url` FFI call succeeds, the wrapper asserts the result is a Go string. A non-nil result of any other Go type triggers this error with %T showing the actual type. It signals a serde/FFI contract violation between the Go client and the Rust runtime, not bad user input.","triggerScenarios":"Calling AsUrl() when the deserialized FFI result is a non-string type (e.g. []byte) due to a mismatch between Go-side expectations and the runtime's actual return type.","commonSituations":"Installing a newer native runtime than the Go module (or vice versa); a runtime change to as_url's return type not yet reflected in the pinned Go client.","solutions":["Update the baml Go dependency and native runtime to the same release","Rebuild/reinstall to clear stale cached binaries","File an issue with BAML including the %T reported in the message if versions match"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"url, err := media.AsUrl()\nif err != nil && strings.Contains(err.Error(), \"unexpected type\") {\n    return fmt.Errorf(\"upgrade baml Go module/runtime to fix serde mismatch: %w\", err)\n}","preventionTips":["Keep baml Go module and native runtime on the same version","Rebuild binaries after upgrades to clear stale artifacts","Include the reported %T when filing bugs"],"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-23T08:17:48.524Z"}