diff --git a/CHANGELOG.md b/CHANGELOG.md index f3fe5fd4..ab8f6e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ # nextflow-io/nf-schema: Changelog -# Version 2.3.0 +# Version 2.2.1 ## Bug fixes 1. Fixed a bug in `paramsSummaryMap()` related to the processing of workflow config files. +2. Fixed a bug where `validation.defaultIgnoreParams` and `validation.ignoreParams` would not actually ignore the parameter validation. # Version 2.2.0 - Kitakata diff --git a/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy b/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy index 76bb66f6..6ea155b9 100644 --- a/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy +++ b/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy @@ -330,8 +330,12 @@ class SchemaValidator extends PluginExtensionPoint { // Validate List validationErrors = validator.validate(paramsJSON, schema_string) this.errors.addAll(validationErrors) - if (this.hasErrors()) { - def msg = "${colors.red}The following invalid input values have been detected:\n\n" + errors.join('\n').trim() + "\n${colors.reset}\n" + def List modifiedIgnoreParams = config.ignoreParams.collect { param -> "* --${param}" as String } + def List filteredErrors = errors.findAll { error -> + return modifiedIgnoreParams.find { param -> error.startsWith(param) } == null + } + if (filteredErrors.size() > 0) { + def msg = "${colors.red}The following invalid input values have been detected:\n\n" + filteredErrors.join('\n').trim() + "\n${colors.reset}\n" log.error("Validation of pipeline parameters failed!") throw new SchemaValidationException(msg, this.getErrors()) } diff --git a/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy b/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy index bad520d9..5cee31b2 100644 --- a/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy +++ b/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy @@ -52,6 +52,5 @@ class ValidationConfig { } ignoreParams += config.defaultIgnoreParams ?: [] ignoreParams += 'nf_test_output' //ignore `nf_test_output` directory when using nf-test - } } \ No newline at end of file diff --git a/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF b/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF index a946f05a..24225ea6 100644 --- a/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF +++ b/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Plugin-Id: nf-schema -Plugin-Version: 2.2.0 +Plugin-Version: 2.2.1 Plugin-Class: nextflow.validation.ValidationPlugin Plugin-Provider: nextflow Plugin-Requires: >=23.10.0 diff --git a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy index 2591e355..4407b83e 100644 --- a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy +++ b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy @@ -483,6 +483,33 @@ class ValidateParametersTest extends Dsl2Spec{ !stdout } + def 'should ignore wrong expected params' () { + given: + def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString() + def SCRIPT = """ + params.input = 1 + params.outdir = 2 + include { validateParameters } from 'plugin/nf-schema' + + validateParameters(parameters_schema: '$schema') + """ + + when: + def config = ["validation": [ + "ignoreParams": ['input'], + "defaultIgnoreParams": ['outdir'] + ]] + def result = new MockScriptRunner(config).setScript(SCRIPT).execute() + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + def 'should fail for unexpected param' () { given: def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()