{"record":{"id":"05245dfaef869a80","repo":"BoundaryML/baml","slug":"unexpected-type-for-name-t","errorCode":null,"errorMessage":"unexpected type for name: %T","messagePattern":"unexpected type for name: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_collector.go","lineNumber":49,"sourceCode":"\t}\n\n\tusage, ok := result.(Usage)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for usage: %T\", result)\n\t}\n\n\treturn usage, nil\n}\n\nfunc (c *collector) Name() (string, error) {\n\tresult, err := raw_objects.CallMethod(c, \"name\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get name: %w\", err)\n\t}\n\n\tname, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for name: %T\", result)\n\t}\n\n\treturn name, nil\n}\n\nfunc (c *collector) Logs() ([]FunctionLog, error) {\n\tresult, err := raw_objects.CallMethod(c, \"logs\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get logs: %w\", err)\n\t}\n\n\tlogs, ok := result.([]raw_objects.RawPointer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for logs: %T\", result)\n\t}\n\n\tfunctionLogs := make([]FunctionLog, len(logs))\n\tfor i, log := range logs {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_collector.go#L31-L67","documentation":"After Collector.Name() retrieves a value from the runtime, it asserts the result is a Go string. If the FFI decoder returns any other type (int pointer, raw object, nil, etc.), this error is thrown. The call reached the runtime fine; the returned payload just did not decode to the expected string, meaning the runtime/bindings contract was broken.","triggerScenarios":"Calling collector.Name() when the runtime's `name` method returns a non-string value — a wrongly-typed decoded object, nil, or a numeric handle due to a decoder type-tag mismatch.","commonSituations":"Version drift between the Go client and native runtime; a collector object created by a mismatched runtime; an anonymous collector whose name resolves to a non-string placeholder.","solutions":["Align the Go module and BAML runtime versions; reinstall both together.","Recreate the collector as a named collector (b.Collector(\"my-name\", ...)) and retry.","Log the %T value from the error and search BAML issues for that type to see if it's a known decoder bug.","If persistent, file a bug with the reproduction and the printed type."],"exampleFix":"// before\nname, err := collector.Name()\n// after\nname, err := collector.Name()\nif err != nil {\n    return \"\", fmt.Errorf(\"unexpected name payload from runtime: %w\", err)\n}","handlingStrategy":"type-guard","validationCode":"// Validate collector identity before reading:\n// if collector == nil { return errors.New(\"nil collector\") }","typeGuard":"func isString(result any) bool {\n    s, ok := result.(string)\n    return ok && s != \"\"\n}","tryCatchPattern":"name, err := collector.Name()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for name\") {\n        return \"\", fmt.Errorf(\"runtime returned non-string name (version mismatch?): %w\", err)\n    }\n    return \"\", err\n}","preventionTips":["Match Go module and native runtime versions","Create named collectors explicitly rather than anonymous ones","Recreate collectors if you ever see decoder type-tag errors"],"tags":["go","ffi","type-assertion","collector"],"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"}