BoundaryML/baml · error

failed to get http response: %w

Error message

failed to get http response: %w

What it means

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.

Source

Thrown at engine/language_client_go/pkg/rawobjects_llm_call.go:81

func (l *llmCall) HttpRequest() (HTTPRequest, error) {
	result, err := raw_objects.CallMethod(l, "http_request", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get http request: %w", err)
	}

	request, ok := result.(HTTPRequest)
	if !ok {
		return nil, fmt.Errorf("unexpected type for http request: %T", result)
	}

	return request, nil
}

func (l *llmCall) HttpResponse() (HTTPResponse, error) {
	result, err := raw_objects.CallMethod(l, "http_response", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get http response: %w", err)
	}

	if result == nil {
		return nil, nil
	}

	response, ok := result.(HTTPResponse)
	if !ok {
		return nil, fmt.Errorf("unexpected type for http response: %T", result)
	}

	return response, nil
}

func (l *llmCall) Usage() (Usage, error) {
	result, err := raw_objects.CallMethod(l, "usage", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get usage: %w", err)

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Only inspect HttpResponse() after the function call/stream has completed.
  2. Treat the error as object-lifecycle related: consume the call object within its producing callback/scope.
  3. Update bindings and runtime to matching versions and regenerate.
  4. Unwrap the error for the underlying FFI cause; remember (nil, nil) is the legitimate 'no response' signal.

Example fix

// before: reading response mid-stream
resp, err := call.HttpResponse()

// after: read after completion
result, err := ctx.Poll() // wait until done
if err == nil {
    resp, err := call.HttpResponse()
    if err != nil { log.Printf("response unavailable: %v", err) }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Wait for completion before reading the response:
// if !call.Finished() { return errors.New("response not ready") }

Try / catch

resp, err := call.HttpResponse()
if err != nil {
    log.Printf("http response unavailable: %v", err)
    return
}
if resp == nil {
    // legitimately no response; handle as 'absent', not an error
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/591bad97b58bea88. Report an issue: GitHub.