Skip to content

Commit 803c1ae

Browse files
authored
Merge pull request #78 from nextflow-io/fix/defaultIgnoreParams
fix ignore configs not working
2 parents 51069b9 + 8ef771b commit 803c1ae

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# nextflow-io/nf-schema: Changelog
22

3-
# Version 2.3.0
3+
# Version 2.2.1
44

55
## Bug fixes
66

77
1. Fixed a bug in `paramsSummaryMap()` related to the processing of workflow config files.
8+
2. Fixed a bug where `validation.defaultIgnoreParams` and `validation.ignoreParams` would not actually ignore the parameter validation.
89

910
# Version 2.2.0 - Kitakata
1011

plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,12 @@ class SchemaValidator extends PluginExtensionPoint {
330330
// Validate
331331
List<String> validationErrors = validator.validate(paramsJSON, schema_string)
332332
this.errors.addAll(validationErrors)
333-
if (this.hasErrors()) {
334-
def msg = "${colors.red}The following invalid input values have been detected:\n\n" + errors.join('\n').trim() + "\n${colors.reset}\n"
333+
def List<String> modifiedIgnoreParams = config.ignoreParams.collect { param -> "* --${param}" as String }
334+
def List<String> filteredErrors = errors.findAll { error ->
335+
return modifiedIgnoreParams.find { param -> error.startsWith(param) } == null
336+
}
337+
if (filteredErrors.size() > 0) {
338+
def msg = "${colors.red}The following invalid input values have been detected:\n\n" + filteredErrors.join('\n').trim() + "\n${colors.reset}\n"
335339
log.error("Validation of pipeline parameters failed!")
336340
throw new SchemaValidationException(msg, this.getErrors())
337341
}

plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,5 @@ class ValidationConfig {
5252
}
5353
ignoreParams += config.defaultIgnoreParams ?: []
5454
ignoreParams += 'nf_test_output' //ignore `nf_test_output` directory when using nf-test
55-
5655
}
5756
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Plugin-Id: nf-schema
3-
Plugin-Version: 2.2.0
3+
Plugin-Version: 2.2.1
44
Plugin-Class: nextflow.validation.ValidationPlugin
55
Plugin-Provider: nextflow
66
Plugin-Requires: >=23.10.0

plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,33 @@ class ValidateParametersTest extends Dsl2Spec{
483483
!stdout
484484
}
485485

486+
def 'should ignore wrong expected params' () {
487+
given:
488+
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
489+
def SCRIPT = """
490+
params.input = 1
491+
params.outdir = 2
492+
include { validateParameters } from 'plugin/nf-schema'
493+
494+
validateParameters(parameters_schema: '$schema')
495+
"""
496+
497+
when:
498+
def config = ["validation": [
499+
"ignoreParams": ['input'],
500+
"defaultIgnoreParams": ['outdir']
501+
]]
502+
def result = new MockScriptRunner(config).setScript(SCRIPT).execute()
503+
def stdout = capture
504+
.toString()
505+
.readLines()
506+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
507+
508+
then:
509+
noExceptionThrown()
510+
!stdout
511+
}
512+
486513
def 'should fail for unexpected param' () {
487514
given:
488515
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()

0 commit comments

Comments
 (0)