{"record":{"id":"cfd66e871db3e49a","repo":"BoundaryML/baml","slug":"failed-to-get-client-name-w","errorCode":null,"errorMessage":"failed to get client name: %w","messagePattern":"failed to get client name: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":39,"sourceCode":"}\n\nfunc (l *llmCall) pointer() int64 {\n\treturn l.RawObject.Pointer()\n}\n\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 {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L21-L57","documentation":"LLMCall.ClientName() wraps any error returned by the underlying FFI CallMethod(l, \"client_name\", nil) when reading the client name of an LLM call from the BAML runtime. It means the runtime could not resolve or return the \"client_name\" attribute for this call object — typically because the object handle is invalid, already freed, or the internal method call across the Go/Rust boundary failed. This is a low-level binding failure, not a client-configuration problem in your BAML code.","triggerScenarios":"Calling ClientName() on an llmCall whose RawObject pointer no longer resolves (e.g. the object was garbage-collected/freed on the Rust side), or when CallMethod cannot dispatch \"client_name\" on the object type, or the runtime returns an error for the attribute lookup.","commonSituations":"Holding an LLMCall reference from a function stream/callback after the BAML runtime finished and cleaned up its objects; version mismatch between the Go bindings and the native BAML runtime where the \"client_name\" method is missing; accessing the call from a different goroutine/thread than the runtime expects.","solutions":["Read client_name within the callback/function-call scope where the LLMCall was delivered, before the runtime can clean it up.","Regenerate/upgrade the BAML Go bindings so the Go client and native runtime versions match (baml-cli generate / go get -u github.com/boundaryml/baml).","Inspect the wrapped error (%w) with errors.Unwrap to see the underlying FFI reason before retrying.","If you only need the client name for logging, prefer the FunctionLLMCall event/trace payload instead of probing the raw object after the fact."],"exampleFix":"// before: keeping the call object beyond the callback\nvar cached baml.LLMCall\nonEvent := func(ev baml.Event) { cached = ev.Call() }\n...\nname, err := cached.ClientName() // failed to get client name\n\n// after: consume attributes inside the event scope\nonEvent := func(ev baml.Event) {\n    name, err := ev.Call().ClientName()\n    if err != nil {\n        log.Printf(\"client name unavailable: %v\", err)\n        return\n    }\n    log.Printf(\"client=%s\", name)\n}","handlingStrategy":"try-catch","validationCode":"// No pre-call validation possible; ensure the runtime is alive and versions match before use.\nif bamlRuntimeVersion != goBindingVersion {\n    log.Fatal(\"BAML Go bindings and native runtime version mismatch\")\n}","typeGuard":null,"tryCatchPattern":"name, err := call.ClientName()\nif err != nil {\n    log.Printf(\"client name unavailable: %v\", err)\n    name = \"unknown\"\n}","preventionTips":["Access LLMCall attributes inside the callback/event scope that produced them.","Keep Go binding and BAML runtime versions in lockstep.","Never store llmCall references for post-hoc access after runtime cleanup.","Avoid touching runtime-owned objects from other goroutines."],"tags":["ffi","runtime","binding","baml"],"backgroundTag":"internal-invariant-violation","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"}