{"record":{"id":"591bad97b58bea88","repo":"BoundaryML/baml","slug":"failed-to-get-http-response-w","errorCode":null,"errorMessage":"failed to get http response: %w","messagePattern":"failed to get http response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_llm_call.go","lineNumber":81,"sourceCode":"\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)\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)","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_llm_call.go#L63-L99","documentation":"LLMCall.HttpResponse() wraps any error from CallMethod(l, \"http_response\", nil) when reading the HTTP response object of the LLM call. It means the runtime failed to resolve the \"http_response\" attribute across the FFI boundary. Note the accessor itself returns (nil, nil) when the response is legitimately absent — this error is only for lookup failures, typically a stale or invalid object handle.","triggerScenarios":"Calling HttpResponse() on an llmCall whose RawObject was freed by the runtime, or when dispatching \"http_response\" returns an error (e.g. before the call has produced a response object internally and the runtime errors instead of returning null).","commonSituations":"Querying the response during a stream before completion while using a runtime version that errors instead of returning nil; accessing the object after runtime shutdown; version mismatch between Go bindings and native runtime.","solutions":["Only inspect HttpResponse() after the function call/stream has completed.","Treat the error as object-lifecycle related: consume the call object within its producing callback/scope.","Update bindings and runtime to matching versions and regenerate.","Unwrap the error for the underlying FFI cause; remember (nil, nil) is the legitimate 'no response' signal."],"exampleFix":"// before: reading response mid-stream\nresp, err := call.HttpResponse()\n\n// after: read after completion\nresult, err := ctx.Poll() // wait until done\nif err == nil {\n    resp, err := call.HttpResponse()\n    if err != nil { log.Printf(\"response unavailable: %v\", err) }\n}","handlingStrategy":"try-catch","validationCode":"// Wait for completion before reading the response:\n// if !call.Finished() { return errors.New(\"response not ready\") }","typeGuard":null,"tryCatchPattern":"resp, err := call.HttpResponse()\nif err != nil {\n    log.Printf(\"http response unavailable: %v\", err)\n    return\n}\nif resp == nil {\n    // legitimately no response; handle as 'absent', not an error\n}","preventionTips":["Only read the response after the call/stream completes.","Remember (nil, nil) means 'no response', not failure.","Consume call objects within their lifecycle scope.","Keep binding/runtime versions matched."],"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"}