BoundaryML/baml · error

unexpected type in logs: %T

Error message

unexpected type in logs: %T

What it means

Thrown inside Collector.Logs() at rawobjects_collector.go:70 when an element of the returned []raw_objects.RawPointer slice fails the FunctionLog interface assertion. The runtime returned a log slice containing an object that is not a FunctionLog (e.g. an LLM call log of a different kind).

Source

Thrown at engine/language_client_go/pkg/rawobjects_collector.go:70

	return name, nil
}

func (c *collector) Logs() ([]FunctionLog, error) {
	result, err := raw_objects.CallMethod(c, "logs", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get logs: %w", err)
	}

	logs, ok := result.([]raw_objects.RawPointer)
	if !ok {
		return nil, fmt.Errorf("unexpected type for logs: %T", result)
	}

	functionLogs := make([]FunctionLog, len(logs))
	for i, log := range logs {
		cast, ok := log.(FunctionLog)
		if !ok {
			return nil, fmt.Errorf("unexpected type in logs: %T", log)
		}
		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)

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Match Go client and native runtime versions (rebuild).
  2. Inspect the %T in the message to identify which concrete type leaked in.
  3. Report upstream if versions match — this is an internal invariant.

Example fix

// before
logs, _ := collector.Logs()
// after
logs, err := collector.Logs()
if err != nil {
	return fmt.Errorf("collector logs unusable: %w", err)
}
Defensive patterns

Strategy: type-guard

Validate before calling

if collector == nil { return errors.New("collector not initialized") }

Type guard

func firstLog(c baml.Collector) (baml.FunctionLog, bool) {
	logs, err := c.Logs()
	if err != nil || len(logs) == 0 { return nil, false }
	return logs[0], true
}

Try / catch

logs, err := collector.Logs()
var bad baml.FunctionLog
_ = bad
if err != nil { return fmt.Errorf("logs unavailable: %w", err) }

Prevention

When it happens

Trigger: collector.Logs() where the collector holds raw objects registered under a type that does not implement FunctionLog.

Common situations: Version drift between the Go bindings and the native runtime causing raw objects to be wrapped with the wrong Go adapter; passing a Collector used for non-function traces.

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


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