BoundaryML/baml · error

failed to get timing: %w

Error message

failed to get timing: %w

What it means

This error wraps any failure from raw_objects.CallMethod when Timing() fetches the 'timing' attribute of a FunctionLog via the C FFI. It is a pass-through wrapper; the actual cause (empty FFI response buffer, nil pointer, proto unmarshal failure, or object-response decode failure) is in the wrapped error. It means the runtime did not return a usable timing object.

Source

Thrown at engine/language_client_go/pkg/rawobjects_function_log.go:72

func (f *functionLog) LogType() (string, error) {
	result, err := raw_objects.CallMethod(f, "log_type", nil)
	if err != nil {
		return "", fmt.Errorf("failed to get log type: %w", err)
	}

	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 {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Unwrap the error to see the underlying FFI failure mode ('failed to call object method function', 'nil pointer', decode failure).
  2. Read Timing() during the lifetime of the owning function call/stream, not afterwards.
  3. Keep the generated Go client and BAML runtime versions in sync (re-run `baml generate`).
  4. Escalate to a bug report if the wrapped error is an unmarshal/decode failure on a live object.
Defensive patterns

Strategy: try-catch

Validate before calling

if fnLog == nil {
    return errors.New("function log is nil; cannot read Timing")
}

Type guard

func isCallMethodFailure(err error) bool {
    return strings.Contains(err.Error(), "failed to call object method")
}

Try / catch

timing, err := fnLog.Timing()
if err != nil {
    log.Printf("Timing unavailable: %v (wrapped: %v)", err, errors.Unwrap(err))
    return fmt.Errorf("baml timing inaccessible: %w", err)
}

Prevention

When it happens

Trigger: Calling Timing() on a functionLog whose runtime object is invalid or already freed; the FFI call returns an empty buffer; the protobuf InvocationResponse fails to unmarshal or decodeObjectResponse fails.

Common situations: Accessing logs after the function stream completed and objects were reclaimed; long-lived services caching log references; Go client vs BAML runtime version mismatch.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/d0a54a743be28746. Report an issue: GitHub.