BoundaryML/baml · error

failed to get log by id

Error message

failed to get log by id: %w

What it means

Go raw-objects collector error: the cross-language CallMethod('id') used to fetch a function log by ID returned an error from the underlying runtime. The %w wraps the RPC/bridge failure itself (unknown id, runtime error); it fires before the result type-assertion, so it is not a Go-side type problem.

Solutions

  1. Verify the functionId actually ran and was tracked by this collector.
  2. Check the wrapped error for a runtime-side not-found vs FFI failure.
  3. List available logs via collector.Logs() to find valid ids.
  4. Ensure the runtime that owns the collector is still alive.

Example fix

// before
log, _ := collector.Id(fnId)
// after
log, err := collector.Id(fnId)
if err != nil {
	return fmt.Errorf("lookup %q failed: %w", fnId, err)
}
Defensive patterns

Strategy: validation

Validate before calling

if functionId == "" { return errors.New("functionId required") }
logs, _ := collector.Logs()
found := false
for _, l := range logs { if l.Id() == functionId { found = true } }
if !found { return fmt.Errorf("function %q not tracked by this collector", functionId) }

Try / catch

log, err := collector.Id(functionId)
if err != nil {
	return fmt.Errorf("no log for function %q: %w", functionId, err)
}

Prevention

When it happens

Trigger: collector.Id(functionId) where the runtime rejects the lookup — unknown/unregistered function id, stale collector handle, or runtime-side error during the call.

Common situations: Querying a function id that never logged in this collector; typos in the function id; using a collector from a different runtime session.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

	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)
	}

	return log, nil
}

func (c *collector) Clear() (int64, error) {
	result, err := raw_objects.CallMethod(c, "clear", nil)
	if err != nil {
		return 0, fmt.Errorf("failed to clear: %w", err)
	}

	count, ok := result.(int64)
	if !ok {

View on GitHub (pinned to bd85ce9dee)