{"record":{"id":"a00ad41b3ea3ddbc","repo":"BoundaryML/baml","slug":"failed-to-get-calls-count-w","errorCode":null,"errorMessage":"failed to get calls count: %w","messagePattern":"failed to get calls count: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_function_log.go","lineNumber":114,"sourceCode":"\nfunc (f *functionLog) RawLLMResponse() (string, error) {\n\tresult, err := raw_objects.CallMethod(f, \"raw_llm_response\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get raw LLM response: %w\", err)\n\t}\n\n\tresponse, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for raw LLM response: %T\", result)\n\t}\n\n\treturn response, nil\n}\n\nfunc (f *functionLog) CallsCount() (int, error) {\n\tresult, err := raw_objects.CallMethod(f, \"calls_count\", nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to get calls count: %w\", err)\n\t}\n\n\tcount, ok := result.(int)\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unexpected type for calls count: %T\", result)\n\t}\n\n\treturn count, nil\n}\n\nfunc (f *functionLog) Calls() ([]LLMCall, error) {\n\tresult, err := raw_objects.CallMethod(f, \"calls\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get calls: %w\", err)\n\t}\n\n\tresult_cast := result.([]raw_objects.RawPointer)\n\tcalls := make([]LLMCall, len(result_cast))","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_function_log.go#L96-L132","documentation":"CallsCount() fetches the number of LLM calls recorded in a function log by invoking the remote 'calls_count' method through raw_objects.CallMethod. This error wraps any failure of that bridge call (transport, marshaling, method-not-found, runtime error). It is the wrapping variant, not the type-check variant.","triggerScenarios":"Calling FunctionLog.CallsCount() when the underlying runtime object is stale/disposed, the 'calls_count' method is missing or renamed, or the runtime raises an exception while computing the count.","commonSituations":"Version mismatch where the runtime no longer exposes 'calls_count'; accessing a function log after its backing object was garbage-collected in the runtime; network/IPC transport failures to the language runtime.","solutions":["Log the wrapped error (%w chain) to find the root cause from the bridge","Verify the runtime object still exposes a 'calls_count' method (check runtime version vs Go bindings)","Re-acquire the function log object instead of reusing a possibly-disposed one"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// no pre-call check possible; ensure the FunctionLog handle is fresh:\nif flog == nil { return 0, errors.New(\"nil function log\") }","typeGuard":null,"tryCatchPattern":"count, err := flog.CallsCount()\nif err != nil {\n    return 0, fmt.Errorf(\"calls count unavailable: %w\", err)\n}","preventionTips":["Do not cache FunctionLog handles across runtime restarts","Verify runtime version compatibility with the Go bindings","Check runtime process health before querying many logs"],"tags":["go","rpc","error-wrapping","llm"],"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"}