{"record":{"id":"188cc8d604ae7f0c","repo":"BoundaryML/baml","slug":"unexpected-type-for-http-response-t","errorCode":null,"errorMessage":"unexpected type for http response: %T","messagePattern":"unexpected type for http response: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":90,"sourceCode":"\t\treturn nil, fmt.Errorf(\"unexpected type for http request: %T\", result)\n\t}\n\n\treturn request, nil\n}\n\nfunc (l *llmCall) HttpResponse() (HTTPResponse, error) {\n\tresult, err := raw_objects.CallMethod(l, \"http_response\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get http response: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tresponse, ok := result.(HTTPResponse)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for http response: %T\", result)\n\t}\n\n\treturn response, nil\n}\n\nfunc (l *llmCall) Usage() (Usage, error) {\n\tresult, err := raw_objects.CallMethod(l, \"usage\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get usage: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tusage, ok := result.(Usage)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for usage: %T\", result)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L72-L108","documentation":"LLMCall.HttpResponse() asserts the runtime result implements HTTPResponse; this error fires when the deserialized FFI value has a different type (%T reveals it). It means the runtime returned an unexpected payload shape for the http_response attribute — a Go-binding/runtime contract mismatch. A nil result is handled earlier and returns (nil, nil), so this only fires on a present-but-wrong-typed value.","triggerScenarios":"raw_objects.CallMethod(l, \"http_response\", nil) returns a non-nil value failing the response.(HTTPResponse) assertion at rawobjects_llm_call.go:88-91 — e.g. an HTTPRequest object or a raw CFFI wrapper.","commonSituations":"Version skew between Go bindings and native runtime changing how http_response is typed; a runtime bug returning a request object where a response was expected; objects created by a different runtime instance.","solutions":["Upgrade and regenerate BAML bindings so both sides agree on the response object type.","Inspect the %T value to see what was actually returned and report persistent mismatches.","Handle the error gracefully in tracing/logging code paths.","Ensure you never swapped request/response objects when storing call metadata."],"exampleFix":"// before\nresp, err := call.HttpResponse()\nif err != nil { return err }\n\n// after\nresp, err := call.HttpResponse()\nif err != nil {\n    log.Printf(\"http response type mismatch: %v\", err)\n    resp = nil\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isHTTPResponse(v interface{}) (baml.HTTPResponse, bool) {\n    resp, ok := v.(baml.HTTPResponse)\n    return resp, ok\n}","tryCatchPattern":"resp, err := call.HttpResponse()\nif err != nil {\n    log.Printf(\"http response type mismatch: %v\", err)\n    return nil\n}","preventionTips":["Synchronize Go binding and native runtime versions.","Capture %T on mismatch for debugging.","Handle nil response separately from type errors.","Never swap stored request/response references."],"tags":["type-assertion","ffi","binding","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-14T11:17:12.474Z"}