BoundaryML/baml · error

failed to get status

Error message

failed to get status: %w

What it means

Thrown by httpResponse.Status() in BAML's Go client when raw_objects.CallMethod(h, "status") fails at the FFI boundary; the underlying core error is wrapped with %w. It means the "status" method could not be invoked on the raw response object, not that the status value is wrong.

Solutions

  1. Unwrap the error to inspect the core-side cause (errors.Unwrap)
  2. Re-obtain the HTTPResponse from the current runtime rather than a cached/stale handle
  3. Align Go bindings and BAML core versions
  4. Guard callers so a status-lookup failure does not abort the whole flow (default to 0 and log)

Example fix

status, err := resp.Status()
if err != nil {
    log.Printf("status unavailable: %v", err)
    status = 0 // proceed without status instead of crashing the pipeline
}
Defensive patterns

Strategy: fallback

Validate before calling

if resp == nil { return errors.New("nil HTTPResponse") }

Try / catch

status, err := resp.Status()
if err != nil {
    log.Printf("status lookup failed: %v", err)
    status = 0
}

Prevention

When it happens

Trigger: Calling HTTPResponse.Status() on a raw object handle that the core cannot resolve or that does not support the "status" method — e.g. stale pointer, object from a torn-down runtime, or bindings/core version drift renaming the method.

Common situations: Accessing response metadata in BAML callback/event-log handlers after the runtime released objects; mixing binding versions after an upgrade.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at engine/language_client_go/pkg/rawobjects_http_response.go:44

func (h *httpResponse) RequestId() (string, error) {
	result, err := raw_objects.CallMethod(h, "id", nil)
	if err != nil {
		return "", fmt.Errorf("failed to get id: %w", err)
	}

	id, ok := result.(string)
	if !ok {
		return "", fmt.Errorf("unexpected type for id: %T", result)
	}

	return id, nil
}

func (h *httpResponse) Status() (int64, error) {
	result, err := raw_objects.CallMethod(h, "status", nil)
	if err != nil {
		return 0, fmt.Errorf("failed to get status: %w", err)
	}

	status, ok := result.(int64)
	if !ok {
		return 0, fmt.Errorf("unexpected type for status: %T", result)
	}

	return status, nil
}

func (h *httpResponse) Headers() (map[string]string, error) {
	result, err := raw_objects.CallMethod(h, "headers", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get headers: %w", err)
	}

	headers, ok := result.(map[string]string)
	if !ok {

View on GitHub (pinned to bd85ce9dee)