{"record":{"id":"3a67dc37a55aca33","repo":"BoundaryML/baml","slug":"unexpected-type-for-selected-call-t","errorCode":null,"errorMessage":"unexpected type for selected call: %T","messagePattern":"unexpected type for selected call: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_function_log.go","lineNumber":149,"sourceCode":"\tresult_cast := result.([]raw_objects.RawPointer)\n\tcalls := make([]LLMCall, len(result_cast))\n\n\tfor i, call := range result_cast {\n\t\tcalls[i] = call.(LLMCall)\n\t}\n\n\treturn calls, nil\n}\n\nfunc (f *functionLog) SelectedCall() (LLMCall, error) {\n\tresult, err := raw_objects.CallMethod(f, \"selected_call\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get selected call: %w\", err)\n\t}\n\n\tcall, ok := result.(LLMCall)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for selected call: %T\", result)\n\t}\n\n\treturn call, nil\n}\n\nfunc (f *functionLog) Tags() (map[string]any, error) {\n\tresult, err := raw_objects.CallMethod(f, \"tags\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get tags: %w\", err)\n\t}\n\n\ttags, ok := result.(map[string]any)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for tags: %T\", result)\n\t}\n\n\treturn tags, nil\n}","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_function_log.go#L131-L167","documentation":"SelectedCall() type-asserts the bridge result to the LLMCall interface; when the runtime returns something else (nil, a raw RawPointer not yet wrapped, or another object) the assertion fails and this error is thrown. It signals the runtime returned an object not conforming to the expected call wrapper.","triggerScenarios":"Calling FunctionLog.SelectedCall() when the 'selected_call' method returns nil (no selection) or an unwrapped raw pointer instead of an LLMCall-conforming wrapper.","commonSituations":"Querying selection before the function log has selected a call; bridge layer returning raw RawPointer because wrapper construction failed; newer runtime returning a changed object shape.","solutions":["Check %T to see whether nil or an unwrapped type is coming back","Handle the no-selection case explicitly before calling SelectedCall","Update the binding so raw RawPointer results are wrapped into LLMCall before assertion"],"exampleFix":"// before\ncall, ok := result.(LLMCall)\nif !ok {\n    return nil, fmt.Errorf(\"unexpected type for selected call: %T\", result)\n}\n// after\nif result == nil {\n    return nil, errors.New(\"no call selected\")\n}\nif ptr, ok := result.(raw_objects.RawPointer); ok {\n    result = wrapLLMCall(ptr)\n}\ncall, ok := result.(LLMCall)\nif !ok {\n    return nil, fmt.Errorf(\"unexpected type for selected call: %T\", result)\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func asLLMCall(v any) (LLMCall, bool) {\n    if v == nil {\n        return nil, false\n    }\n    if ptr, ok := v.(raw_objects.RawPointer); ok {\n        v = wrapLLMCall(ptr)\n    }\n    c, ok := v.(LLMCall)\n    return c, ok\n}","tryCatchPattern":"call, err := flog.SelectedCall()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for selected call\") {\n        return nil, fmt.Errorf(\"selection missing or malformed: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Handle the nil-selection case before calling SelectedCall","Ensure the bridge wraps raw pointers into LLMCall before returning","Report binding/runtime shape drift with the %T value from the error"],"tags":["go","type-assertion","interface","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"}