BoundaryML/baml · error

unexpected type from source: %T

Error message

unexpected type from source: %T

What it means

The llmRenderable From() helper asks the native runtime whether the AST node came from source via the "from_source" method, expecting a bool. If the deserialized result is not a bool, it returns "unexpected type from source: %T" with ASTNodeSource_Unknown. The message text is also (confusingly) reused by Name() below.

Solutions

  1. Align the generated Go client with the native runtime version
  2. Re-acquire the renderable from a fresh BAML runtime instance
  3. If the error persists on valid nodes, file a binding bug with the %T value

Example fix

// before
src, err := bamlRenderable.From()
// after
src, err := bamlRenderable.From()
if err != nil {
    return ASTNodeSource_Unknown // caller already receives Unknown; log and degrade
}
Defensive patterns

Strategy: try-catch

Try / catch

// Go
src, err := renderable.From()
if err != nil {
    return ASTNodeSource_Unknown // From() already returns Unknown on error
}

Prevention

When it happens

Trigger: Calling From() on a renderable whose native "from_source" returns nil or a non-bool, typically due to runtime/binding version skew or an invalidated native object.

Common situations: Introspecting AST nodes from a baml runtime compiled with a different protocol than the Go client; nodes that never resolved to a source file.

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

Appendix: source

Thrown at engine/language_client_go/pkg/rawobjects_llmrenderable.go:77

	}

	alias, ok := result.(string)
	if !ok {
		return nil, nil
	}

	return &alias, nil
}

func (eb *llmRenderableObject) From() (ASTNodeSource, error) {
	result, err := raw_objects.CallMethod(eb, "is_from_ast", nil)
	if err != nil {
		return ASTNodeSource_Unknown, err
	}

	fromSource, ok := result.(bool)
	if !ok {
		return ASTNodeSource_Unknown, fmt.Errorf("unexpected type from source: %T", result)
	}

	if fromSource {
		return ASTNodeSource_Baml, nil
	}

	return ASTNodeSource_TypeBuilder, nil
}

func (eb *llmRenderableObject) Name() (string, error) {
	result, err := raw_objects.CallMethod(eb, "name", nil)
	if err != nil {
		return "", err
	}

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

View on GitHub (pinned to bd85ce9dee)