From 830c5299589ee0b9720d61d73b86d299cbab148e Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Wed, 24 Jul 2024 10:32:16 -0500 Subject: [PATCH 1/2] Add runtime error for missing channel factory Signed-off-by: Ben Sherman --- .../nextflow/plugin/extension/PluginExtensionProvider.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/nextflow/src/main/groovy/nextflow/plugin/extension/PluginExtensionProvider.groovy b/modules/nextflow/src/main/groovy/nextflow/plugin/extension/PluginExtensionProvider.groovy index 0ca983a6c1..31ad82587e 100644 --- a/modules/nextflow/src/main/groovy/nextflow/plugin/extension/PluginExtensionProvider.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/plugin/extension/PluginExtensionProvider.groovy @@ -286,6 +286,9 @@ class PluginExtensionProvider implements ExtensionProvider { def factory = (ChannelFactoryInstance)reference.target return factory.invokeExtensionMethod(reference.method, args) } + else { + throw new MissingMethodException("Channel.${name}", Object.class, args) + } } } From 8c2079929508e3f2f1933139838edea711d39c5c Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 27 Jul 2024 12:12:32 +0200 Subject: [PATCH 2/2] Add tests [ci fast] Signed-off-by: Paolo Di Tommaso --- .../nextflow/script/ScriptDslTest.groovy | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/nextflow/src/test/groovy/nextflow/script/ScriptDslTest.groovy b/modules/nextflow/src/test/groovy/nextflow/script/ScriptDslTest.groovy index 9e48c8e55e..3758ad497a 100644 --- a/modules/nextflow/src/test/groovy/nextflow/script/ScriptDslTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/script/ScriptDslTest.groovy @@ -604,4 +604,26 @@ class ScriptDslTest extends Dsl2Spec { result.val == 'Hello' } + + def 'should throw an exception on missing method' () { + + when: + dsl_eval ''' + Channel.doesNotExist() + ''' + then: + def e1 = thrown(MissingMethodException) + e1.message == 'No signature of method: java.lang.Object.Channel.doesNotExist() is applicable for argument types: () values: []' + + when: + dsl_eval ''' + workflow { + Channel.doesNotExist() + } + ''' + then: + def e2 = thrown(MissingProcessException) + e2.message == 'Missing process or function Channel.doesNotExist()' + } + }