{"record":{"id":"02c6860623804a34","repo":"BoundaryML/baml","slug":"failed-to-get-http-request-w","errorCode":null,"errorMessage":"failed to get http request: %w","messagePattern":"failed to get http request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":67,"sourceCode":"\nfunc (l *llmCall) Provider() (string, error) {\n\tresult, err := raw_objects.CallMethod(l, \"provider\", nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get provider: %w\", err)\n\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","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L49-L85","documentation":"LLMCall.HttpRequest() wraps any error from CallMethod(l, \"http_request\", nil) when fetching the HTTP request object associated with the LLM call. It means the runtime failed to resolve the \"http_request\" attribute — usually a stale/freed object handle or an FFI dispatch failure. Without this the caller cannot inspect the outbound LLM API request.","triggerScenarios":"Calling HttpRequest() on an llmCall whose backing RawObject was released by the Rust runtime, or when the \"http_request\" method call itself returns an error across the FFI boundary.","commonSituations":"Deferring HTTP request inspection until after the BAML function completed and objects were cleaned up; version mismatch between Go bindings and native runtime; concurrent access to runtime-owned handles from multiple goroutines.","solutions":["Inspect HttpRequest() inside the callback/scope that produced the LLMCall.","Keep the runtime alive (e.g. don't stop/close the BAML runtime) until all call objects have been consumed.","Match Go binding and native runtime versions, then regenerate bindings.","Unwrap the error to identify the precise FFI failure before attempting alternatives."],"exampleFix":"// before\nreq, err := call.HttpRequest()\n// err: failed to get http request (object freed)\n\n// after: consume in event scope\nonEvent := func(ev baml.Event) {\n    req, err := ev.Call().HttpRequest()\n    if err != nil {\n        log.Printf(\"request unavailable: %v\", err)\n        return\n    }\n    _ = req\n}","handlingStrategy":"try-catch","validationCode":"// Consume the request while the runtime guarantees liveness:\nfunc inspectRequest(ev baml.Event) {\n    if ev.Call() == nil { return } // must be inside event scope\n}","typeGuard":null,"tryCatchPattern":"req, err := call.HttpRequest()\nif err != nil {\n    log.Printf(\"http request unavailable: %v\", err)\n    return\n}","preventionTips":["Inspect HTTP request data inside the producing callback.","Do not shut down the runtime before all call objects are consumed.","Keep bindings and runtime versions synchronized.","Avoid cross-goroutine access to runtime-owned handles."],"tags":["ffi","runtime","binding","http","baml"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}