BoundaryML/baml · error

failed to get is base64: %w

Error message

failed to get is base64: %w

What it means

Wraps any error from the FFI call to the runtime's `is_base64` method, which reports whether the media content is base64-encoded data. The wrapper preserves the underlying cause with %w, so the wrapped error carries the real failure from the Rust runtime.

Source

Thrown at engine/language_client_go/pkg/rawobjects_media.go:113

		return nil, fmt.Errorf("unexpected type for mime type: %T", result)
	}

	return &as_mime_type, nil
}

func (m *mediaHolder) IsUrl() (bool, error) {
	result, err := raw_objects.CallMethod(m, "is_url", nil)
	if err != nil {
		return false, fmt.Errorf("failed to get is url: %w", err)
	}

	return result.(bool), nil
}

func (m *mediaHolder) IsBase64() (bool, error) {
	result, err := raw_objects.CallMethod(m, "is_base64", nil)
	if err != nil {
		return false, fmt.Errorf("failed to get is base64: %w", err)
	}

	return result.(bool), nil
}

func (m *mediaHolder) AsUrl() (*string, error) {
	result, err := raw_objects.CallMethod(m, "as_url", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get as url: %w", err)
	}

	if result == nil {
		return nil, nil
	}

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

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Read the wrapped cause via errors.Unwrap to diagnose
  2. Rebuild the media object from a new BAML call result
  3. Upgrade the baml Go module and baml-cli together
  4. Verify the media source (file/URL/base64 string) was well-formed when constructed
Defensive patterns

Strategy: try-catch

Validate before calling

if media == nil { return fmt.Errorf("media object is nil") }

Try / catch

isB64, err := media.IsBase64()
if err != nil {
    log.Printf("is_base64 failed: %v", errors.Unwrap(err))
    isB64 = false
}

Prevention

When it happens

Trigger: Calling IsBase64() on a media object whose CFFI handle is stale/invalid or whose remote `is_base64` method fails in the runtime.

Common situations: Long-lived references to media from an earlier LLM call; mismatched Go client and runtime versions; runtime bug or corrupted media payload.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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