{"record":{"id":"13ed62828add3edf","repo":"BoundaryML/baml","slug":"unexpected-type-for-body-t-rawobjects-http-response","errorCode":null,"errorMessage":"unexpected type for body: %T","messagePattern":"unexpected type for body: %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_http_response.go","lineNumber":77,"sourceCode":"\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}\n","sourceCodeStart":59,"sourceCodeEnd":82,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_http_response.go#L59-L82","documentation":"Thrown by httpResponse.Body() when the FFI call succeeded but the decoded result does not implement the HTTPBody interface. The %T verb names the concrete Go type that arrived. It indicates the body object was decoded into a type the Go bindings do not recognize as an HTTPBody, usually from version drift between the BAML core and the Go bindings.","triggerScenarios":"Calling HTTPResponse.Body() when the core returns a body object decoded as a generic RawObject or an unrecognized body variant rather than an httpBody implementation.","commonSituations":"Mixed engine/binding versions; event-log bodies produced by a newer BAML release; unhandled body encoding added on the core side without a matching Go decoder.","solutions":["Upgrade the Go bindings and BAML core to matching versions","Check the %T in the error and look for the missing case in the pkg/cffi body decoder","Fall back to reading raw body bytes via other available accessors if the typed body is unusable","File a BAML issue with the %T value if versions already match"],"exampleFix":"body, err := resp.Body()\nif err != nil {\n    log.Printf(\"typed body unavailable: %v\", err)\n    return err\n}","handlingStrategy":"type-guard","validationCode":"if resp == nil { return errors.New(\"nil HTTPResponse\") }","typeGuard":"func safeTypedBody(resp baml.HTTPResponse) (baml.HTTPBody, bool) {\n    b, err := resp.Body()\n    return b, err == nil\n}","tryCatchPattern":"body, err := resp.Body()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type\") {\n        return fmt.Errorf(\"body decode drift (check version match): %w\", err)\n    }\n    return err\n}","preventionTips":["Upgrade bindings and engine together","Treat typed body reads as fallible in event pipelines","Log the %T from the error for diagnostics"],"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"}