{"record":{"id":"0f9e5f1c8209df58","repo":"BoundaryML/baml","slug":"failed-to-get-selected-w","errorCode":null,"errorMessage":"failed to get selected: %w","messagePattern":"failed to get selected: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":117,"sourceCode":"\t\treturn nil, fmt.Errorf(\"failed to get usage: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\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 {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L99-L135","documentation":"BAML's Go binding wraps a Rust/CFFI runtime. llmCall.Selected() calls raw_objects.CallMethod(l, \"selected\", nil) across the FFI boundary; if the native layer fails to answer the \"selected\" method call, the Go wrapper wraps the underlying error with \"failed to get selected\". This is a transport/bridge failure, not a normal application error.","triggerScenarios":"Calling Selected() on an LLMCall object whose underlying native pointer has been invalidated, freed, or whose runtime returned an error for the \"selected\" method (e.g. after runtime shutdown or an internal Rust-side panic surfaced as an error).","commonSituations":"Using an llmCall retrieved from a completed/cancelled function call after the runtime was torn down; version mismatch between generated BAML client code and the native baml runtime library; accessing the call concurrently while the runtime resets state.","solutions":["Print the wrapped cause with errors.Unwrap or %v to see the underlying FFI error and fix that first","Re-fetch the llmCall from a fresh BAML function invocation instead of reusing a stale handle","Ensure the BAML runtime is initialized and not shut down before calling Selected()","Align the generated Go client and the native baml library versions"],"exampleFix":"// before\nselected, err := call.Selected()\n// after\nselected, err := call.Selected()\nif err != nil {\n    log.Printf(\"selected lookup failed: %v\", err) // inspect wrapped cause\n    return false\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go\nselected, err := call.Selected()\nif err != nil {\n    log.Printf(\"failed to get selected: %v\", err)\n    return false\n}","preventionTips":["Call Selected() promptly on a fresh llmCall from a completed BAML invocation","Keep the BAML runtime alive for the lifetime of all call objects","Keep generated client and native runtime versions in sync"],"tags":["go","ffi","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-23T08:17:48.524Z"}