BoundaryML/baml · error
unexpected type for id: %T
Error message
unexpected type for id: %T
What it means
Thrown by httpResponse.RequestId() when the FFI CallMethod("id") succeeded but the decoded result is not a Go string. The %T verb reports the actual decoded type. This indicates the core returned the id in an unexpected representation (e.g. an integer or wrapped object) relative to what the Go bindings expect.
Source
Thrown at engine/language_client_go/pkg/rawobjects_http_response.go:35
}
func (h *httpResponse) ObjectType() cffi.BamlObjectType {
return cffi.BamlObjectType_OBJECT_HTTP_RESPONSE
}
func (h *httpResponse) pointer() int64 {
return h.RawObject.Pointer()
}
func (h *httpResponse) RequestId() (string, error) {
result, err := raw_objects.CallMethod(h, "id", nil)
if err != nil {
return "", fmt.Errorf("failed to get id: %w", err)
}
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
}View on GitHub (pinned to bd85ce9dee)
Solutions
- Upgrade the Go bindings and BAML core to the same release so the id is decoded as a string
- Check the %T in the error to identify the actual decoded type and search pkg/cffi for the corresponding decoder
- Fall back to LLMCall.RequestId() which reads http_request_id if the response id is unusable
- Report to BAML maintainers with the %T value if versions are already aligned
Example fix
id, err := resp.RequestId()
if err != nil {
// guard against non-string decode
return fmt.Errorf("request id not usable: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if resp == nil { return errors.New("nil HTTPResponse") } Try / catch
id, err := resp.RequestId()
if err != nil {
if strings.Contains(err.Error(), "unexpected type") {
return "", fmt.Errorf("id decode drift, check versions: %w", err)
}
return "", err
} Prevention
- Upgrade bindings and engine together
- Log the %T value from the error when reporting issues
- Use LLMCall.RequestId() as a fallback correlation key
When it happens
Trigger: Calling HTTPResponse.RequestId() when the core's id field decodes to a non-string CFFI value — typically after a version mismatch where the id representation changed between the core and Go bindings.
Common situations: Upgraded BAML core with older Go bindings (or vice versa); event-log data produced by a different BAML version; corrupted decoding of the id payload.
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 status: %T
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/8aba08463ed5167b.
Report an issue: GitHub.