{"record":{"id":"81203cf764fc2c28","repo":"BoundaryML/baml","slug":"unexpected-type-for-http-request-t","errorCode":null,"errorMessage":"unexpected type for http request: %T","messagePattern":"unexpected type for http request: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":72,"sourceCode":"\t}\n\n\tprovider, ok := result.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unexpected type for provider: %T\", result)\n\t}\n\n\treturn provider, nil\n}\n\nfunc (l *llmCall) HttpRequest() (HTTPRequest, error) {\n\tresult, err := raw_objects.CallMethod(l, \"http_request\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get http request: %w\", err)\n\t}\n\n\trequest, ok := result.(HTTPRequest)\n\tif !ok {\n\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)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L54-L90","documentation":"LLMCall.HttpRequest() type-asserts the runtime result to the HTTPRequest interface; this error fires when the deserialized FFI value is not a HTTPRequest (%T shows the actual type). It means the runtime returned an unexpected payload shape for the http_request attribute — a binding/runtime contract mismatch.","triggerScenarios":"raw_objects.CallMethod(l, \"http_request\", nil) returns a value failing the request.(HTTPRequest) assertion at rawobjects_llm_call.go:70-73 — e.g. a raw wrapper struct, nil, or wrong object type (such as an HTTPResponse).","commonSituations":"Version skew between the Go bindings and the native runtime encoding http_request differently; a runtime regression returning a mismatched object type; mixing call objects across runtime instances.","solutions":["Upgrade the Go bindings and BAML runtime to matching versions and regenerate.","Check the %T in the message to identify the wrong type returned, and report if it persists.","Guard logging/diagnostics code so a type mismatch degrades gracefully.","Ensure the object you are querying is genuinely an LLM call, not another BAML object type."],"exampleFix":"// before\nreq, err := call.HttpRequest()\nif err != nil { return err }\n\n// after\nreq, err := call.HttpRequest()\nif err != nil {\n    log.Printf(\"http request type mismatch: %v\", err)\n    return nil // degrade instead of failing the pipeline\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isHTTPRequest(v interface{}) (baml.HTTPRequest, bool) {\n    req, ok := v.(baml.HTTPRequest)\n    return req, ok\n}","tryCatchPattern":"req, err := call.HttpRequest()\nif err != nil {\n    log.Printf(\"http request type mismatch: %v\", err)\n    return nil\n}","preventionTips":["Upgrade bindings and runtime together.","Record %T on mismatch and file a bug if reproducible.","Verify object identity (LLM call vs other BAML objects) before access.","Make trace pipelines tolerant of accessor failures."],"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"}