BoundaryML/baml · error
unexpected type for timing: %T
Error message
unexpected type for timing: %T
What it means
Returned by Timing() when the 'timing' call succeeded but the value failed the `result.(Timing)` assertion — the runtime returned a Go value that is not the Timing interface/struct the client expects. This is a client-runtime FFI contract guard: the decoded object is of an unexpected concrete type, pointing to version skew, a decoder bug, or a corrupted object rather than anything the caller did wrong.
Source
Thrown at engine/language_client_go/pkg/rawobjects_function_log.go:77
}
logType, ok := result.(string)
if !ok {
return "", fmt.Errorf("unexpected type for log type: %T", result)
}
return logType, nil
}
func (f *functionLog) Timing() (Timing, error) {
result, err := raw_objects.CallMethod(f, "timing", nil)
if err != nil {
return nil, fmt.Errorf("failed to get timing: %w", err)
}
timing, ok := result.(Timing)
if !ok {
return nil, fmt.Errorf("unexpected type for timing: %T", result)
}
return timing, nil
}
func (f *functionLog) Usage() (Usage, error) {
result, err := raw_objects.CallMethod(f, "usage", nil)
if err != nil {
return nil, fmt.Errorf("failed to get usage: %w", err)
}
usage, ok := result.(Usage)
if !ok {
return nil, fmt.Errorf("unexpected type for usage: %T", result)
}
return usage, nil
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Regenerate the Go client so its cffi bindings match the BAML runtime version.
- Check the %T in the message to see the actual returned type.
- Only consume the FunctionLog while its stream/request is still alive.
- Report upstream with versions and the printed type if reproducible on a fresh object.
Defensive patterns
Strategy: type-guard
Validate before calling
if fnLog == nil {
return errors.New("function log is nil; cannot read Timing")
} Type guard
func timingIsTiming(v any) bool {
_, ok := v.(Timing)
return ok
} Try / catch
timing, err := fnLog.Timing()
if err != nil {
if strings.Contains(err.Error(), "unexpected type for timing:") {
return nil, fmt.Errorf("timing object contract mismatch (version skew?): %w", err)
}
return nil, err
} Prevention
- Regenerate the client whenever the BAML runtime changes its object representations.
- Log the %T type from the error when diagnosing.
- Read Timing() during the function stream's lifetime.
- Pin client and runtime versions together.
When it happens
Trigger: timing decodes into a different raw object class (e.g. a plain map/class instead of the Timing raw object); mismatched client and runtime versions; stale functionLog objects.
Common situations: Partial upgrade where the BAML engine emits a new timing representation but the Go client predates it; reusing logs post-stream; internal decode errors producing the wrong object variant.
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 ID: %T
- unexpected type for function name: %T
- unexpected type for log type: %T
- unexpected type for usage: %T
- unexpected type for mime type: %T
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/97ac656a1cc8cc96.
Report an issue: GitHub.