{"record":{"id":"b30c0d8e39a5296b","repo":"BoundaryML/baml","slug":"unexpected-type-for-provider-t","errorCode":null,"errorMessage":"unexpected type for provider: %T","messagePattern":"unexpected type for provider: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":58,"sourceCode":"\t}\n\n\tname, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for client name: %T\", result)\n\t}\n\n\treturn name, nil\n}\n\nfunc (l *llmCall) Provider() (string, error) {\n\tresult, err := raw_objects.CallMethod(l, \"provider\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get provider: %w\", err)\n\t}\n\n\tprovider, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for provider: %T\", result)\n\t}\n\n\treturn provider, nil\n}\n\nfunc (l *llmCall) HttpRequest() (HTTPRequest, error) {\n\tresult, err := raw_objects.CallMethod(l, \"http_request\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get http request: %w\", err)\n\t}\n\n\trequest, ok := result.(HTTPRequest)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for http request: %T\", result)\n\t}\n\n\treturn request, nil\n}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L40-L76","documentation":"LLMCall.Provider() asserts the runtime's \"provider\" result is a Go string; this error fires when the deserialized FFI value has a different type (%T reveals it). It signals that the runtime returned an unexpected payload shape for the provider attribute — a Go-binding/runtime contract mismatch, not a caller mistake.","triggerScenarios":"raw_objects.CallMethod(l, \"provider\", nil) returns a non-string value that fails the provider.(string) assertion at rawobjects_llm_call.go:56-59 — e.g. a CFFI wrapper object, bytes, or nil.","commonSituations":"Out-of-sync Go binding and native runtime versions encoding \"provider\" differently; a runtime schema change; a runtime bug returning the provider as a wrapped object rather than a string.","solutions":["Upgrade and regenerate BAML bindings so Go client and native runtime agree on wire types.","Note the actual type in %T and report the mismatch to BoundaryML with your version pair.","Handle the error gracefully (log + default) instead of letting it abort tracing/logging paths.","Verify you are not mixing objects from two runtime instances (e.g. after a reload)."],"exampleFix":"// before\nprovider, err := call.Provider()\nif err != nil { return err }\n\n// after\nprovider, err := call.Provider()\nif err != nil {\n    log.Printf(\"provider type mismatch: %v\", err)\n    provider = \"unknown\"\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"func safeProvider(call baml.LLMCall) string {\n    p, err := call.Provider()\n    if err != nil {\n        return \"unknown\"\n    }\n    return p\n}","tryCatchPattern":"provider, err := call.Provider()\nif err != nil {\n    log.Printf(\"provider type mismatch: %v\", err)\n    provider = \"unknown\"\n}","preventionTips":["Regenerate bindings after BAML upgrades.","Capture %T on mismatch for diagnostics.","Default provider to a safe string in observability code.","Avoid mixing objects across runtime instances."],"tags":["type-assertion","ffi","binding","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-14T11:17:12.474Z"}