BoundaryML/baml · error
unexpected type for status: %T
Error message
unexpected type for status: %T
What it means
Thrown by httpResponse.Status() when the FFI call succeeded but the decoded result is not a Go int64. The %T verb names the actual type. The BAML core encodes HTTP status as an integer; a different decoded type signals encoding drift or an unexpected payload from the core.
Source
Thrown at engine/language_client_go/pkg/rawobjects_http_response.go:49
}
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 {
return 0, fmt.Errorf("unexpected type for status: %T", result)
}
return status, nil
}
func (h *httpResponse) Headers() (map[string]string, error) {
result, err := raw_objects.CallMethod(h, "headers", nil)
if err != nil {
return nil, fmt.Errorf("failed to get headers: %w", err)
}
headers, ok := result.(map[string]string)
if !ok {
return nil, fmt.Errorf("unexpected type for headers: %T", result)
}
return headers, nil
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Upgrade the Go bindings and BAML core to matching versions
- Read the %T in the error to identify what arrived and check pkg/cffi integer decoding
- Cast defensively only after verifying the type via errors message inspection
- File an issue with BAML including the %T value if versions match
Example fix
status, err := resp.Status()
if err != nil {
return fmt.Errorf("non-integer status decoded: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if resp == nil { return errors.New("nil HTTPResponse") } Try / catch
status, err := resp.Status()
if err != nil {
if strings.Contains(err.Error(), "unexpected type") {
return 0, fmt.Errorf("status decode drift: %w", err)
}
return 0, err
} Prevention
- Keep bindings and core on the same version
- Treat status as int64 only via the accessor
- Capture the %T value when filing bug reports
When it happens
Trigger: Calling HTTPResponse.Status() when the core returns the status as a non-int64 CFFI value — typically from a version mismatch between the Rust core and the Go bindings, or a decoder bug mapping the status field.
Common situations: Partially upgraded BAML installations; reading objects produced by a different engine version; hand-rolled or patched bindings that changed the status encoding.
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 class property builders: %T
- unexpected type for class property builder: %T
- unexpected type for class property type: %T
- unexpected type for body: %T
- unexpected type for id: %T
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/fe7518c8ba16a015.
Report an issue: GitHub.