{"record":{"id":"e0787701c0c8f82d","repo":"BoundaryML/baml","slug":"unexpected-type-for-class-property-type-t","errorCode":null,"errorMessage":"unexpected type for class property type: %T","messagePattern":"unexpected type for class property type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/pkg/rawobjects_class_property_builder.go","lineNumber":44,"sourceCode":"\n// Type sets the type for the property\nfunc (cpb *classPropertyBuilder) SetType(fieldType Type) error {\n\targs := map[string]interface{}{\n\t\t\"field_type\": fieldType,\n\t}\n\t_, err := raw_objects.CallMethod(cpb, \"set_type\", args)\n\treturn err\n}\n\nfunc (cpb *classPropertyBuilder) Type() (Type, error) {\n\tresult, err := raw_objects.CallMethod(cpb, \"type_\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttyp, ok := result.(Type)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected type for class property type: %T\", result)\n\t}\n\n\treturn typ, nil\n}\n","sourceCodeStart":26,"sourceCodeEnd":49,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/pkg/rawobjects_class_property_builder.go#L26-L49","documentation":"ClassPropertyBuilder.Type() asks the runtime for the property's type via the `type_` method and asserts the result implements the Type interface. If the FFI call yields any other Go type, this error is returned. It means the runtime did not return a proper type-definition object, typically because of a bindings/runtime mismatch or a degraded FFI result.","triggerScenarios":"Calling ClassPropertyBuilder.Type() when CallMethod returns something other than a Type — e.g. nil, a raw pointer that failed type resolution, or a value decoded with an unexpected object type.","commonSituations":"Introspecting dynamic classes with mismatched Go client and native runtime versions; the property was added with a field type the runtime could not re-materialize; corrupted or stale shared runtime artifacts.","solutions":["Align the Go module version with the installed BAML runtime and reinstall both.","Check that the property's declared field type (the Type passed to AddProperty) came from the same runtime instance, not a foreign object.","Recreate the class builder/property pipeline and retry to rule out corrupt runtime state.","File a BAML issue including the %T value from the message if it persists."],"exampleFix":"// before\ntyp, err := propBuilder.Type()\n// after\ntyp, err := propBuilder.Type()\nif err != nil {\n    return nil, fmt.Errorf(\"could not resolve property type (runtime mismatch?): %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Validate the property builder is non-nil and from the same session\n// if propBuilder == nil { return errors.New(\"propBuilder required\") }","typeGuard":"func isType(result any) bool {\n    _, ok := result.(Type)\n    return ok\n}","tryCatchPattern":"typ, err := propBuilder.Type()\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected type for class property type\") {\n        return nil, fmt.Errorf(\"Type() FFI contract violation: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Use Type values returned by the same runtime that owns the property builder","Keep runtime artifacts and Go bindings version-matched","Recreate builders after any BAML upgrade instead of caching them"],"tags":["go","ffi","type-assertion","baml"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}