{"record":{"id":"adb315e994bd7cb0","repo":"BoundaryML/baml","slug":"failed-to-get-function-name-w","errorCode":null,"errorMessage":"failed to get function name: %w","messagePattern":"failed to get function name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_function_log.go","lineNumber":44,"sourceCode":"\nfunc (f *functionLog) Id() (string, error) {\n\tresult, err := raw_objects.CallMethod(f, \"id\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get ID: %w\", err)\n\t}\n\n\tid, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for ID: %T\", result)\n\t}\n\n\treturn id, nil\n}\n\nfunc (f *functionLog) FunctionName() (string, error) {\n\tresult, err := raw_objects.CallMethod(f, \"function_name\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get function name: %w\", err)\n\t}\n\n\tname, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for function name: %T\", result)\n\t}\n\n\treturn name, nil\n}\n\nfunc (f *functionLog) LogType() (string, error) {\n\tresult, err := raw_objects.CallMethod(f, \"log_type\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get log type: %w\", err)\n\t}\n\n\tlogType, ok := result.(string)\n\tif !ok {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_function_log.go#L26-L62","documentation":"This error wraps any failure from raw_objects.CallMethod when FunctionName() asks the BAML runtime (via the C FFI) for the 'function_name' attribute of a FunctionLog. It is a pass-through wrapper: the real cause (failed FFI call, nil pointer, proto unmarshal failure, or object-response decode failure) is in the wrapped error. It means the Go client could not successfully retrieve this property from the runtime object.","triggerScenarios":"Calling FunctionName() on a functionLog when the underlying runtime object pointer is invalid or already destroyed, the runtime returns an empty/nil buffer ('failed to call object method function'), or protobuf unmarshalling/decoding of the response fails.","commonSituations":"Iterating logs from a finished function stream after the runtime cleaned them up; stale collector/log references held across long-lived processes; version skew between the generated Go client and the BAML runtime library.","solutions":["Read the wrapped cause via errors.Unwrap / %w output to identify whether it is 'failed to call object method function', 'object method function returned nil pointer', or a decode failure.","Ensure you access the FunctionLog while the function call/stream it belongs to is still valid; don't cache log objects beyond the request lifetime.","Align the Go client version with the BAML runtime (re-run `baml generate` so the client and engine match).","If the underlying error is a decode/unmarshal failure, report it upstream with your baml CLI and client versions; it indicates an FFI contract mismatch."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if fnLog == nil {\n    return errors.New(\"function log is nil; cannot read FunctionName\")\n}","typeGuard":"func isCallMethodFailure(err error) bool {\n    return errors.Is(err, errCallFailed) || strings.Contains(err.Error(), \"failed to call object method\")\n}","tryCatchPattern":"name, err := fnLog.FunctionName()\nif err != nil {\n    log.Printf(\"FunctionName unavailable: %v (wrapped: %v)\", err, errors.Unwrap(err))\n    return fmt.Errorf(\"baml function log inaccessible: %w\", err)\n}","preventionTips":["Always log the unwrapped cause — this error is a wrapper and the root cause is beneath it.","Access logs during the owning function call/stream lifetime.","Regenerate the client after any BAML runtime/CLI upgrade.","Don't share functionLog objects across goroutines or process boundaries."],"tags":["go","ffi","wrapped-error","baml"],"backgroundTag":"unexpected-response-shape","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"}