{"record":{"id":"0df4445233a03d32","repo":"BoundaryML/baml","slug":"failed-to-clear-w","errorCode":null,"errorMessage":"failed to clear: %w","messagePattern":"failed to clear: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_collector.go","lineNumber":115,"sourceCode":"\tresult, err := raw_objects.CallMethod(c, \"id\", map[string]any{\n\t\t\"id\": functionId,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get log by id: %w\", err)\n\t}\n\n\tlog, ok := result.(FunctionLog)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for log by id: %T\", result)\n\t}\n\n\treturn log, nil\n}\n\nfunc (c *collector) Clear() (int64, error) {\n\tresult, err := raw_objects.CallMethod(c, \"clear\", nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to clear: %w\", err)\n\t}\n\n\tcount, ok := result.(int64)\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unexpected type for clear result: %T\", result)\n\t}\n\n\treturn count, nil\n}\n","sourceCodeStart":97,"sourceCodeEnd":125,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_collector.go#L97-L125","documentation":"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.","triggerScenarios":"collector.Clear() when the runtime call itself errors — stale collector pointer across runtime teardown, FFI marshalling failure, or native-side clear error.","commonSituations":"Clearing a collector after the BAML runtime shut down; version-skewed binaries where the 'clear' method signature changed.","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."],"exampleFix":"// before\ncount, _ := collector.Clear()\n// after\ncount, err := collector.Clear()\nif err != nil {\n\treturn fmt.Errorf(\"clear failed: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if collector == nil { return errors.New(\"collector not initialized\") }","typeGuard":null,"tryCatchPattern":"count, err := collector.Clear()\nif err != nil {\n\treturn fmt.Errorf(\"collector.Clear failed: %w\", err)\n}","preventionTips":["Clear collectors only while their runtime is running.","Unwrap the error chain for the native-side cause.","Reinstall matched binaries after upgrades before clearing."],"tags":["go","ffi","collector"],"backgroundTag":"api-request-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}