@@ -942,10 +942,7 @@ impl TypeSpace {
942942 if has_null {
943943 self . convert_null ( metadata)
944944 } else {
945- Err ( Error :: InvalidSchema {
946- type_name : type_name. into_option ( ) ,
947- reason : "empty enum array" . to_string ( ) ,
948- } )
945+ self . convert_never ( type_name, original_schema)
949946 }
950947 } else {
951948 let mut ty = TypeEntryEnum :: from_metadata (
@@ -1948,9 +1945,12 @@ impl TypeSpace {
19481945 metadata : & ' a Option < Box < Metadata > > ,
19491946 enum_values : & [ serde_json:: Value ] ,
19501947 ) -> Result < ( TypeEntry , & ' a Option < Box < Metadata > > ) > {
1948+ if enum_values. is_empty ( ) {
1949+ return self . convert_never ( type_name, original_schema) ;
1950+ }
1951+
19511952 // We're here because the schema didn't have a type; that's a bummer,
19521953 // but we'll do our best to roll with the punches.
1953- assert ! ( !enum_values. is_empty( ) ) ;
19541954
19551955 // Let's hope all these values are the same type.
19561956 let mut instance_types = enum_values
@@ -1976,10 +1976,14 @@ impl TypeSpace {
19761976 . cloned ( )
19771977 . collect :: < Vec < _ > > ( ) ;
19781978
1979- let ( type_entry, metadata) =
1980- self . convert_unknown_enum ( type_name, original_schema, metadata, & enum_values) ?;
1981- let type_entry = self . type_to_option ( type_entry) ;
1982- Ok ( ( type_entry, metadata) )
1979+ if enum_values. is_empty ( ) {
1980+ self . convert_null ( metadata)
1981+ } else {
1982+ let ( type_entry, metadata) =
1983+ self . convert_unknown_enum ( type_name, original_schema, metadata, & enum_values) ?;
1984+ let type_entry = self . type_to_option ( type_entry) ;
1985+ Ok ( ( type_entry, metadata) )
1986+ }
19831987 } else {
19841988 match ( instance_types. len ( ) , instance_types. iter ( ) . next ( ) ) {
19851989 ( 1 , Some ( InstanceType :: String ) ) => self . convert_enum_string (
0 commit comments