diff --git a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts index bdfeef199..c2b6d5e5e 100644 --- a/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts +++ b/packages/core/src/data_sources/model/collection_component/CollectionComponent.ts @@ -151,17 +151,18 @@ function resolveBlockValues(context: any, block: any): any { const collectionItem = blockValue.collection_name ? context[blockValue.collection_name] : innerMostCollectionItem; - if (!collectionItem) continue; - - switch (blockValue.variable_type) { - case 'current_item': - clonedBlock[key] = blockValue.path - ? resolvePathValue(collectionItem.current_item, blockValue.path) - : JSON.stringify(collectionItem.current_item); - break; - default: - clonedBlock[key] = collectionItem[blockValue.variable_type]; - break; + if (!collectionItem) { + throw new Error( + `Collection not found: ${blockValue.collection_name || 'default collection'}` + ); + } + + if (blockValue.variable_type === 'current_item') { + clonedBlock[key] = blockValue.path + ? resolvePathValue(collectionItem.current_item, blockValue.path) + : JSON.stringify(collectionItem.current_item); + } else { + clonedBlock[key] = collectionItem[blockValue.variable_type]; } } else if (Array.isArray(blockValue)) { // Resolve each item in the array