BoundaryML/baml · error
failed to clear
Error message
failed to clear: %w
What it means
Go raw-objects collector error: the CallMethod('clear') invocation to clear collected logs failed at the bridge level; the %w wraps the underlying runtime error. It fires before the result is interpreted, so the count type-assertion is not the problem.
Solutions
- Check the unwrapped root cause (errors.Unwrap / errors.As).
- Ensure the collector belongs to the currently running runtime.
- Reinstall matched BAML Go client + native binaries.
Example fix
// before
count, _ := collector.Clear()
// after
count, err := collector.Clear()
if err != nil {
return fmt.Errorf("clear failed: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if collector == nil { return errors.New("collector not initialized") } Try / catch
count, err := collector.Clear()
if err != nil {
return fmt.Errorf("collector.Clear failed: %w", err)
} Prevention
- Clear collectors only while their runtime is running.
- Unwrap the error chain for the native-side cause.
- Reinstall matched binaries after upgrades before clearing.
When it happens
Trigger: collector.Clear() when the runtime call itself errors — stale collector pointer across runtime teardown, FFI marshalling failure, or native-side clear error.
Common situations: Clearing a collector after the BAML runtime shut down; version-skewed binaries where the 'clear' method signature changed.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- failed to create collector
- failed to get last log
- failed to get log by id
- failed to get logs
- failed to get name
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/0df4445233a03d32.
Report an issue: GitHub.
Appendix: source
Thrown at engine/language_client_go/pkg/rawobjects_collector.go:115
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 {
return 0, fmt.Errorf("unexpected type for clear result: %T", result)
}
return count, nil
}
View on GitHub (pinned to bd85ce9dee)