BoundaryML/baml · error

unexpected type for provider: %T

Error message

unexpected type for provider: %T

What it means

LLMCall.Provider() asserts the runtime's "provider" result is a Go string; this error fires when the deserialized FFI value has a different type (%T reveals it). It signals that the runtime returned an unexpected payload shape for the provider attribute — a Go-binding/runtime contract mismatch, not a caller mistake.

Source

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

	}

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

	return name, nil
}

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

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

	return provider, nil
}

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
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Upgrade and regenerate BAML bindings so Go client and native runtime agree on wire types.
  2. Note the actual type in %T and report the mismatch to BoundaryML with your version pair.
  3. Handle the error gracefully (log + default) instead of letting it abort tracing/logging paths.
  4. Verify you are not mixing objects from two runtime instances (e.g. after a reload).

Example fix

// before
provider, err := call.Provider()
if err != nil { return err }

// after
provider, err := call.Provider()
if err != nil {
    log.Printf("provider type mismatch: %v", err)
    provider = "unknown"
}
Defensive patterns

Strategy: fallback

Type guard

func safeProvider(call baml.LLMCall) string {
    p, err := call.Provider()
    if err != nil {
        return "unknown"
    }
    return p
}

Try / catch

provider, err := call.Provider()
if err != nil {
    log.Printf("provider type mismatch: %v", err)
    provider = "unknown"
}

Prevention

When it happens

Trigger: raw_objects.CallMethod(l, "provider", nil) returns a non-string value that fails the provider.(string) assertion at rawobjects_llm_call.go:56-59 — e.g. a CFFI wrapper object, bytes, or nil.

Common situations: Out-of-sync Go binding and native runtime versions encoding "provider" differently; a runtime schema change; a runtime bug returning the provider as a wrapped object rather than a string.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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