@@ -97,10 +97,14 @@ pub enum ComponentError {
9797 LayerDb ( #[ from] si_layer_cache:: LayerDbError ) ,
9898 #[ error( "component {0} missing attribute value for code" ) ]
9999 MissingCodeValue ( ComponentId ) ,
100+ #[ error( "missing controlling func data for parent attribute value id: {0}" ) ]
101+ MissingControllingFuncDataForParentAttributeValue ( AttributeValueId ) ,
100102 #[ error( "component {0} missing attribute value for qualifications" ) ]
101103 MissingQualificationsValue ( ComponentId ) ,
102104 #[ error( "component {0} missing attribute value for root" ) ]
103105 MissingRootProp ( ComponentId ) ,
106+ #[ error( "more than one schema variant found for component: {0}" ) ]
107+ MoreThanOneSchemaVariantFound ( ComponentId ) ,
104108 #[ error( "found multiple parents for component: {0}" ) ]
105109 MultipleParentsForComponent ( ComponentId ) ,
106110 #[ error( "found multiple root attribute values ({0} and {1}, at minimum) for component: {2}" ) ]
@@ -607,12 +611,12 @@ impl Component {
607611 let content_hash_discriminants: ContentAddressDiscriminants =
608612 content. content_address ( ) . into ( ) ;
609613 if let ContentAddressDiscriminants :: SchemaVariant = content_hash_discriminants {
610- // TODO(nick): consider creating a new edge weight kind to make this easier.
611- // We also should use a proper error here.
612614 schema_variant_id = match schema_variant_id {
613615 None => Some ( content. id ( ) . into ( ) ) ,
614616 Some ( _already_found_schema_variant_id) => {
615- panic ! ( "already found a schema variant" )
617+ return Err ( ComponentError :: MoreThanOneSchemaVariantFound (
618+ component_id,
619+ ) ) ;
616620 }
617621 } ;
618622 }
@@ -1120,8 +1124,9 @@ impl Component {
11201124 // if av has a parent and parent is controlled by dynamic func, that's the controller
11211125 // else av controls itself
11221126 let controlling_tuple = if let Some ( parent_av_id) = maybe_parent_av_id {
1123- // We can unwrap because if we're on the child, we've added the parent to result
1124- let parent_controlling_data = * result. get ( & parent_av_id) . unwrap ( ) ;
1127+ let parent_controlling_data = * result. get ( & parent_av_id) . ok_or (
1128+ ComponentError :: MissingControllingFuncDataForParentAttributeValue ( parent_av_id) ,
1129+ ) ?;
11251130
11261131 if parent_controlling_data. is_dynamic_func {
11271132 parent_controlling_data
0 commit comments