{"record":{"id":"e2f4d2d51a3fbd66","repo":"BoundaryML/baml","slug":"unexpected-type-for-headers-t-rawobjects-http-response","errorCode":null,"errorMessage":"unexpected type for headers: %T","messagePattern":"unexpected type for headers: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_response.go","lineNumber":63,"sourceCode":"\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 {\n\t\treturn nil, fmt.Errorf(\"unexpected type for body: %T\", result)\n\t}\n\n\treturn body, nil\n}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_response.go#L45-L81","documentation":"Thrown by httpResponse.Headers() when the FFI call succeeded but the decoded result is not a Go map[string]string. The %T verb names the actual decoded type. The core normally encodes headers as a string-to-string map; anything else indicates encoding drift or an unhandled payload shape.","triggerScenarios":"Calling HTTPResponse.Headers() when the core returns headers in an unexpected representation — e.g. a raw list of pairs, an object wrapper, or nil-ish value not decoded as map[string]string, usually after a version mismatch.","commonSituations":"Upgraded core with stale Go bindings; headers decoded by a different engine version; custom provider responses with non-standard header containers.","solutions":["Upgrade the Go bindings and BAML core to the same release","Inspect the %T value and check pkg/cffi map decoding for the missing case","Avoid assuming header presence; treat header reads as optional metadata","Report the %T to BAML maintainers if versions are aligned"],"exampleFix":"headers, err := resp.Headers()\nif err != nil {\n    return fmt.Errorf(\"headers not a string map: %w\", err)\n}","handlingStrategy":"type-guard","validationCode":"if resp == nil { return errors.New(\"nil HTTPResponse\") }","typeGuard":"func asStringMap(v any) map[string]string {\n    m, ok := v.(map[string]string)\n    if !ok { return map[string]string{} }\n    return m\n}","tryCatchPattern":"headers, err := resp.Headers()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        return nil, fmt.Errorf(\"header decode drift: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Upgrade engine and bindings in lockstep","Never assume headers are present in event-log objects","Report unexpected %T values to maintainers"],"tags":["go","type-assertion","ffi","baml"],"backgroundTag":"type-mismatch","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"}