{"record":{"id":"cf8b2118c7f19159","repo":"BoundaryML/baml","slug":"unexpected-type-for-selected-t","errorCode":null,"errorMessage":"unexpected type for selected: %T","messagePattern":"unexpected type for selected: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":122,"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 (l *llmCall) Selected() (bool, error) {\n\tresult, err := raw_objects.CallMethod(l, \"selected\", nil)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to get selected: %w\", err)\n\t}\n\n\tselected, ok := result.(bool)\n\tif !ok {\n\t\treturn false, fmt.Errorf(\"unexpected type for selected: %T\", result)\n\t}\n\n\treturn selected, nil\n}\n\nfunc (l *llmCall) Timing() (Timing, error) {\n\tresult, err := raw_objects.CallMethod(l, \"timing\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get timing: %w\", err)\n\t}\n\n\ttiming, ok := result.(Timing)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for timing: %T\", result)\n\t}\n\n\treturn timing, nil\n}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L104-L140","documentation":"llmCall.Selected() expects the native runtime to return a Go bool for the \"selected\" method. When the FFI layer deserializes the result into some other Go type, the wrapper rejects it with \"unexpected type for selected: %T\". This indicates a contract mismatch between the native runtime and the Go binding.","triggerScenarios":"Calling Selected() when the runtime returns nil or a non-bool (e.g. a wrapped object, string, or nil from a missing/changed \"selected\" method) instead of a Go bool.","commonSituations":"Version skew: generated client built against an older runtime where \"selected\" returned a different shape; a nil/None result from the native side when selection data was never produced (e.g. streaming or a non-selector model).","solutions":["Check the runtime version matches the generated BAML Go client","Verify the LLM call actually ran through a selection-capable path before calling Selected()","Log result type via %T if you control the wrapper; report a binding bug if the native layer is correct"],"exampleFix":"// before\nok, err := call.Selected()\n// after\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        // runtime returned non-bool; treat as not-selected and log\n        log.Printf(\"selection unavailable: %v\", err)\n        return false, nil\n    }\n    return false, err\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Go: verify via errors before trusting the bool\nok, err := call.Selected()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        // runtime returned non-bool; treat as unknown\n        return false\n    }\n    return false\n}","tryCatchPattern":"// Go\nif err != nil {\n    log.Printf(\"selected type mismatch: %v\", err)\n    return false, nil\n}","preventionTips":["Pin baml Go client and native runtime to the same release","Only query Selected() on calls that went through selection-capable flows","Log the raw error (contains %T of the offending type) when diagnosing"],"tags":["go","ffi","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}