BoundaryML/baml · error
unexpected type for selected call: %T
Error message
unexpected type for selected call: %T
What it means
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.
Source
Thrown at engine/language_client_go/pkg/rawobjects_function_log.go:149
result_cast := result.([]raw_objects.RawPointer)
calls := make([]LLMCall, len(result_cast))
for i, call := range result_cast {
calls[i] = call.(LLMCall)
}
return calls, nil
}
func (f *functionLog) SelectedCall() (LLMCall, error) {
result, err := raw_objects.CallMethod(f, "selected_call", nil)
if err != nil {
return nil, fmt.Errorf("failed to get selected call: %w", err)
}
call, ok := result.(LLMCall)
if !ok {
return nil, fmt.Errorf("unexpected type for selected call: %T", result)
}
return call, nil
}
func (f *functionLog) Tags() (map[string]any, error) {
result, err := raw_objects.CallMethod(f, "tags", nil)
if err != nil {
return nil, fmt.Errorf("failed to get tags: %w", err)
}
tags, ok := result.(map[string]any)
if !ok {
return nil, fmt.Errorf("unexpected type for tags: %T", result)
}
return tags, nil
}View on GitHub (pinned to bd85ce9dee)
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
Example fix
// before
call, ok := result.(LLMCall)
if !ok {
return nil, fmt.Errorf("unexpected type for selected call: %T", result)
}
// after
if result == nil {
return nil, errors.New("no call selected")
}
if ptr, ok := result.(raw_objects.RawPointer); ok {
result = wrapLLMCall(ptr)
}
call, ok := result.(LLMCall)
if !ok {
return nil, fmt.Errorf("unexpected type for selected call: %T", result)
} Defensive patterns
Strategy: type-guard
Type guard
func asLLMCall(v any) (LLMCall, bool) {
if v == nil {
return nil, false
}
if ptr, ok := v.(raw_objects.RawPointer); ok {
v = wrapLLMCall(ptr)
}
c, ok := v.(LLMCall)
return c, ok
} Try / catch
call, err := flog.SelectedCall()
if err != nil {
if strings.Contains(err.Error(), "unexpected type for selected call") {
return nil, fmt.Errorf("selection missing or malformed: %w", err)
}
return nil, err
} Prevention
- 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
When it happens
Trigger: Calling FunctionLog.SelectedCall() when the 'selected_call' method returns nil (no selection) or an unwrapped raw pointer instead of an LLMCall-conforming wrapper.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- unexpected type for raw LLM response: %T
- unexpected type for tags: %T
- unexpected type for class type: %T
- unexpected type for class property builders: %T
- unexpected type for class property builder: %T
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/3a67dc37a55aca33.
Report an issue: GitHub.