{"record":{"id":"23e5c20086483141","repo":"BoundaryML/baml","slug":"unexpected-type-for-client-name-t","errorCode":null,"errorMessage":"unexpected type for client name: %T","messagePattern":"unexpected type for client name: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":44,"sourceCode":"\nfunc (l *llmCall) RequestId() (string, error) {\n\tresult, err := raw_objects.CallMethod(l, \"http_request_id\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get request id: %w\", err)\n\t}\n\n\treturn result.(string), nil\n}\n\nfunc (l *llmCall) ClientName() (string, error) {\n\tresult, err := raw_objects.CallMethod(l, \"client_name\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get client name: %w\", err)\n\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}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L26-L62","documentation":"LLMCall.ClientName() asserts that the value returned by the runtime for \"client_name\" is a Go string. This error is thrown when the raw FFI result deserializes to a different Go type (%T prints the actual type), meaning the runtime sent an unexpected payload shape for the attribute. It indicates a Go-binding/runtime contract mismatch rather than anything the caller did wrong.","triggerScenarios":"raw_objects.CallMethod(l, \"client_name\", nil) succeeds but returns a non-string (e.g. a raw CFFI wrapper, []byte, or nil interface) that fails the result.(string) type assertion at rawobjects_llm_call.go:42-45.","commonSituations":"Mismatched versions of the Go bindings and the native BAML runtime where \"client_name\" is encoded differently; a runtime bug or schema change that changed the attribute's type; passing through an object whose client_name was never a string internally.","solutions":["Align Go binding and BAML CLI/runtime versions (go get github.com/boundaryml/baml@latest and regenerate) so the expected wire types match.","Check the %T value in the message to identify what the runtime actually returned, and report/compare against the binding's expected type.","Log the error defensively and fall back to the event payload's client name instead of crashing on the raw accessor.","If reproducible, file a bug with BoundaryML including the %T value and both versions."],"exampleFix":"// before\nname, err := llmCall.ClientName()\nif err != nil { panic(err) }\n\n// after\nname, err := llmCall.ClientName()\nif err != nil {\n    log.Printf(\"client name type mismatch (%v); skipping\", err)\n    name = \"unknown\"\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"func safeClientName(call baml.LLMCall) string {\n    name, err := call.ClientName()\n    if err != nil {\n        return \"unknown\"\n    }\n    return name\n}","tryCatchPattern":"name, err := call.ClientName()\nif err != nil {\n    var s string\n    _ = s\n    log.Printf(\"client name type mismatch: %v\", err)\n    name = \"unknown\"\n}","preventionTips":["Pin and match Go binding/native runtime versions.","Log the %T value whenever this occurs to aid bug reports.","Keep accessor usage wrapped so diagnostics never crash pipelines.","Regenerate bindings after every BAML upgrade."],"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"}