{"record":{"id":"53a55c8c64366b4e","repo":"BoundaryML/baml","slug":"failed-to-get-headers-w-rawobjects-http-response","errorCode":null,"errorMessage":"failed to get headers: %w","messagePattern":"failed to get headers: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_response.go","lineNumber":58,"sourceCode":"\nfunc (h *httpResponse) Status() (int64, error) {\n\tresult, err := raw_objects.CallMethod(h, \"status\", nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to get status: %w\", err)\n\t}\n\n\tstatus, ok := result.(int64)\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unexpected type for status: %T\", result)\n\t}\n\n\treturn status, nil\n}\n\nfunc (h *httpResponse) Headers() (map[string]string, error) {\n\tresult, err := raw_objects.CallMethod(h, \"headers\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get headers: %w\", err)\n\t}\n\n\theaders, ok := result.(map[string]string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for headers: %T\", result)\n\t}\n\n\treturn headers, nil\n}\n\nfunc (h *httpResponse) Body() (HTTPBody, error) {\n\tresult, err := raw_objects.CallMethod(h, \"body\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get body: %w\", err)\n\t}\n\n\tbody, ok := result.(HTTPBody)\n\tif !ok {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_response.go#L40-L76","documentation":"Thrown by httpResponse.Headers() in BAML's Go client when raw_objects.CallMethod(h, \"headers\") fails at the FFI boundary; the core-side error is wrapped with %w. This is a method-invocation failure on the raw object, not a map conversion problem.","triggerScenarios":"Calling HTTPResponse.Headers() on an object whose raw pointer the core cannot resolve or that rejects the \"headers\" method — stale handles, runtime teardown, or bindings/core version drift.","commonSituations":"Header inspection in BAML event-log processors accessing objects after the runtime disposed of them; mismatched baml Go module vs installed engine versions.","solutions":["Unwrap the error to identify the core-side failure","Use only HTTPResponse objects obtained live from the current runtime","Align Go bindings and BAML core versions","Skip header processing gracefully when unavailable (log and continue)"],"exampleFix":"headers, err := resp.Headers()\nif err != nil {\n    log.Printf(\"headers unavailable: %v\", err)\n    headers = map[string]string{} // empty map fallback\n}","handlingStrategy":"fallback","validationCode":"if resp == nil { return errors.New(\"nil HTTPResponse\") }","typeGuard":null,"tryCatchPattern":"headers, err := resp.Headers()\nif err != nil {\n    log.Printf(\"headers lookup failed: %v\", err)\n    headers = map[string]string{}\n}","preventionTips":["Use only live runtime objects for header reads","Provide an empty-map fallback in log-processing code","Match baml engine and Go module versions"],"tags":["go","ffi","baml","method-call"],"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"}