BoundaryML/baml · error

failed to get id

Error message

failed to get id: %w

What it means

Thrown by httpResponse.RequestId() in BAML's Go client when raw_objects.CallMethod(h, "id") fails on the FFI boundary. The returned error from the Rust core (object lookup failure, method not found on the raw object, or expired/invalid pointer) is wrapped with %w. It is not a Go-side type problem; the id method call itself failed.

Solutions

  1. Unwrap the error with errors.Unwrap/errors.As to see the underlying FFI failure before acting
  2. Ensure the HTTPResponse object is still alive and obtained directly from the same runtime (not from a stale log entry or after runtime teardown)
  3. Align Go binding and BAML core versions so the "id" method exists on the core side
  4. If only the id is needed and unavailable, correlate via LLMCall.RequestId() (http_request_id) instead

Example fix

id, err := resp.RequestId()
if err != nil {
    // before: id unavailable, whole operation aborted silently
    // after: inspect the wrapped cause
    return fmt.Errorf("response id lookup failed: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

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

Try / catch

id, err := resp.RequestId()
if err != nil {
    log.Printf("response id unavailable: %v", err)
    id = "" // degrade gracefully
}

Prevention

When it happens

Trigger: Calling HTTPResponse.RequestId() on a response object whose underlying raw pointer cannot serve the "id" method — e.g. the object handle was not properly initialized, the core returned an error for the method invocation, or the object has been released.

Common situations: Inspecting HTTPResponse objects obtained from BAML event logs/callbacks where the raw object registry no longer holds the pointer; version drift between Go bindings and the core library so the "id" method name is unknown to the core.

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/f72f792bcdf07f79. Report an issue: GitHub.

Appendix: source

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

	*raw_objects.RawObject
}

func newHttpResponse(ptr int64, rt unsafe.Pointer) HTTPResponse {
	return &httpResponse{raw_objects.FromPointer(ptr, rt)}
}

func (h *httpResponse) ObjectType() cffi.BamlObjectType {
	return cffi.BamlObjectType_OBJECT_HTTP_RESPONSE
}

func (h *httpResponse) pointer() int64 {
	return h.RawObject.Pointer()
}

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 {

View on GitHub (pinned to bd85ce9dee)