BoundaryML/baml · error
unexpected type for last log: %T %v
Error message
unexpected type for last log: %T %v
What it means
Thrown by Collector.Last() at rawobjects_collector.go:90 when CallMethod("last") returns a non-nil value that does not implement the FunctionLog interface. The runtime returned an object of the wrong kind for 'last'.
Source
Thrown at engine/language_client_go/pkg/rawobjects_collector.go:90
functionLogs[i] = cast
}
return functionLogs, nil
}
func (c *collector) Last() (FunctionLog, error) {
result, err := raw_objects.CallMethod(c, "last", nil)
if err != nil {
return nil, fmt.Errorf("failed to get last log: %w", err)
}
if result == nil {
return nil, nil
}
log, ok := result.(FunctionLog)
if !ok {
return nil, fmt.Errorf("unexpected type for last log: %T %v", result, result)
}
return log, nil
}
func (c *collector) Id(functionId string) (FunctionLog, error) {
result, err := raw_objects.CallMethod(c, "id", map[string]any{
"id": functionId,
})
if err != nil {
return nil, fmt.Errorf("failed to get log by id: %w", err)
}
log, ok := result.(FunctionLog)
if !ok {
return nil, fmt.Errorf("unexpected type for log by id: %T", result)
}
View on GitHub (pinned to bd85ce9dee)
Solutions
- Align Go client and native runtime versions; rebuild.
- Check the printed %T to identify the leaked concrete type.
- File an upstream bug with the type name if versions match.
Example fix
// before
log, _ := collector.Last()
// after
log, err := collector.Last()
if err != nil {
return fmt.Errorf("collector.Last() type error: %w", err)
} Defensive patterns
Strategy: type-guard
Validate before calling
if collector == nil { return errors.New("collector not initialized") } Type guard
func asLog(v any) (baml.FunctionLog, bool) {
l, ok := v.(baml.FunctionLog)
return l, ok
} Try / catch
log, err := collector.Last()
if err != nil {
if strings.Contains(err.Error(), "unexpected type") { /* version mismatch — escalate */ }
return err
} Prevention
- Match Go client and native runtime versions.
- Do not reuse collectors across runtime instances.
- Escalate persistent occurrences as upstream bugs.
When it happens
Trigger: collector.Last() where the native runtime returns a raw object wrapped as something other than a FunctionLog (version mismatch or wrong object registration).
Common situations: Go bindings/native runtime version skew; runtime returning an internal object type not mapped to FunctionLog in the Go layer.
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 logs: %T
- unexpected type in logs: %T
- unexpected type for log by id: %T
- unexpected type for clear result: %T
- failed to get usage: %w
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/6440b4c14ebb0804.
Report an issue: GitHub.