BoundaryML/baml · error
unexpected type for URL: %T
Error message
unexpected type for URL: %T
What it means
httpRequest.Url() expects the runtime 'url' method to return a Go string. 'unexpected type for URL: %T' means the bridge call succeeded but the returned value is not a string (nil, float64, struct, etc.).
Source
Thrown at engine/language_client_go/pkg/rawobjects_http_request.go:49
}
id, ok := result.(string)
if !ok {
return "", fmt.Errorf("unexpected type for ID: %T", result)
}
return id, nil
}
func (h *httpRequest) Url() (string, error) {
result, err := raw_objects.CallMethod(h, "url", nil)
if err != nil {
return "", fmt.Errorf("failed to get URL: %w", err)
}
url, ok := result.(string)
if !ok {
return "", fmt.Errorf("unexpected type for URL: %T", result)
}
return url, nil
}
func (h *httpRequest) Method() (string, error) {
result, err := raw_objects.CallMethod(h, "method", nil)
if err != nil {
return "", fmt.Errorf("failed to get method: %w", err)
}
method, ok := result.(string)
if !ok {
return "", fmt.Errorf("unexpected type for method: %T", result)
}
return method, nil
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Fix the runtime/handler so 'url' returns a plain string
- Check %T in the message to learn the actual type
- If the value is a URL object, extract its string form on the runtime side
- Align client and runtime versions
Defensive patterns
Strategy: try-catch
Validate before calling
u, err := req.Url()
if err == nil && u == "" { log.Printf("warning: empty URL returned") } Type guard
func isString(v any) bool { _, ok := v.(string); return ok } Try / catch
u, err := req.Url()
if err != nil {
if strings.Contains(err.Error(), "unexpected type") {
return fmt.Errorf("runtime URL is not a string: %w", err)
}
return err
} Prevention
- Return plain string URLs from runtime handlers, not URL objects
- Contract-test Url() string return
- Align versions across client and runtime
When it happens
Trigger: The runtime 'url' implementation returns a non-string — e.g. a URL object, nil for malformed requests, or a numeric value.
Common situations: Handlers returning URL objects instead of strings; scripts producing nil URLs for unmatched routes; cross-version schema drift.
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
- unexpected type for logs: %T
- unexpected type in logs: %T
- unexpected type for last log: %T %v
- unexpected type for log by id: %T
- unexpected type for clear result: %T
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/cec6f0bb5eeec606.
Report an issue: GitHub.