From 31d379fc5ae5021750a8b0d675b1d17b35942e7a Mon Sep 17 00:00:00 2001 From: stack72 Date: Fri, 20 Dec 2024 22:47:27 +0000 Subject: [PATCH] fix(sdf): Ensure we match intrinsics schema variants as well as components --- .../service/v2/func/binding/create_binding.rs | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/lib/sdf-server/src/service/v2/func/binding/create_binding.rs b/lib/sdf-server/src/service/v2/func/binding/create_binding.rs index 71d733f1ae..32f4f675b3 100644 --- a/lib/sdf-server/src/service/v2/func/binding/create_binding.rs +++ b/lib/sdf-server/src/service/v2/func/binding/create_binding.rs @@ -97,33 +97,25 @@ pub async fn create_binding( Option, Option, ) = match eventual_parent { - Some(eventual_parent) => { - if let EventualParent::Component(component_id) = eventual_parent - { - ( - Component::get_by_id(&ctx, component_id) - .await? - .name(&ctx) - .await?, - Some(component_id), - None, - ) - } else { - return Err(FuncAPIError::MissingSchemaVariantAndFunc); - } - } - None => { - let schema_variant_id = - attribute_output_location.find_schema_variant(&ctx).await?; - ( + Some(eventual_parent) => match eventual_parent { + EventualParent::SchemaVariant(schema_variant_id) => ( SchemaVariant::get_by_id_or_error(&ctx, schema_variant_id) .await? .display_name() .to_string(), None, Some(schema_variant_id), - ) - } + ), + EventualParent::Component(component_id) => ( + Component::get_by_id(&ctx, component_id) + .await? + .name(&ctx) + .await?, + Some(component_id), + None, + ), + }, + None => (String::new(), None, None), }; let destination_name = attribute_output_location .get_name_of_destination(&ctx)