{"record":{"id":"99db51f95512bb18","repo":"BoundaryML/baml","slug":"unexpected-type-for-start-time-t","errorCode":null,"errorMessage":"unexpected type for start time: %T","messagePattern":"unexpected type for start time: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_timing.go","lineNumber":35,"sourceCode":"}\n\nfunc (t *timing) ObjectType() cffi.BamlObjectType {\n\treturn cffi.BamlObjectType_OBJECT_TIMING\n}\n\nfunc (t *timing) pointer() int64 {\n\treturn t.RawObject.Pointer()\n}\n\nfunc (t *timing) StartTimeUTCMs() (int64, error) {\n\tresult, err := raw_objects.CallMethod(t, \"start_time_utc_ms\", nil)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to get start time: %w\", err)\n\t}\n\n\tstartTime, ok := result.(int64)\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unexpected type for start time: %T\", result)\n\t}\n\n\treturn startTime, nil\n}\n\nfunc (t *timing) DurationMs() (*int64, error) {\n\tresult, err := raw_objects.CallMethod(t, \"duration_ms\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get duration: %w\", err)\n\t}\n\n\tif result == nil {\n\t\treturn nil, nil\n\t}\n\n\tduration, ok := result.(int64)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for duration: %T\", result)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_timing.go#L17-L53","documentation":"After the FFI call \"start_time_utc_ms\" succeeds, StartTimeUTCMs() asserts the returned any is a Go int64. If the bridge decoded the timestamp into any other Go type (e.g. float64, uint64, or a pointer), the assertion fails and this error is thrown. It is an internal contract violation between the CFFI bridge decoder and this wrapper, not something the caller controls.","triggerScenarios":"Calling StartTimeUTCMs() when the bridge's \"start_time_utc_ms\" method returns a non-int64 value (e.g. float64 or uint64 from a changed native encoding).","commonSituations":"Go binding version out of sync with the native BAML runtime so the timestamp is now encoded as a different integer/float type; custom or older cffi decoders.","solutions":["Read the %T in the error message to see which Go type the bridge returned; that reveals the encoding drift.","Upgrade or downgrade the baml Go module so bindings and native runtime use the same FFI encoding (int64 timestamps).","If you cannot change versions, wrap access and convert the alternate numeric type yourself after reflect-based inspection.","Report the decoder bug to boundaryml/baml if versions are aligned and the error persists."],"exampleFix":"// before (library-level assumption)\nstartTime, ok := result.(int64)\n\n// after (caller-side tolerant wrapper)\nfunc startMs(t baml.Timing) (int64, error) {\n    v, err := t.StartTimeUTCMs()\n    if err != nil {\n        return 0, err\n    }\n    return v, nil\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isInt64(v any) bool { _, ok := v.(int64); return ok }","tryCatchPattern":"startMs, err := timing.StartTimeUTCMs()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for start time\") {\n        log.Printf(\"FFI encoding drift on start_time_utc_ms: %v\", err)\n        return 0, nil\n    }\n    return 0, err\n}","preventionTips":["Upgrade/downgrade the baml Go module together with the native runtime to keep int64 FFI encodings stable.","Watch for this error after BAML version bumps; it signals encoder changes.","Include the %T output in bug reports."],"tags":["go","ffi","type-mismatch","timing"],"backgroundTag":"type-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}