Skip to content

Fix validation of plugin config options #5952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
import groovy.transform.PackageScope
import groovy.util.logging.Slf4j
import nextflow.NF
import nextflow.config.ConfigBuilder
import nextflow.config.ConfigValidator
import nextflow.exception.AbortOperationException
Expand Down Expand Up @@ -117,7 +118,10 @@ class CmdConfig extends CmdBase {
final config = builder.buildConfigObject()

// -- validate config options
new ConfigValidator().validate(config)
if( NF.getSyntaxParserVersion() == 'v2' ) {
Plugins.load(config)
new ConfigValidator().validate(config)
}

// -- print config options
if( printValue ) {
Expand Down
3 changes: 2 additions & 1 deletion modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ class CmdRun extends CmdBase implements HubOptions {
Plugins.load(cfg)

// -- validate config options
new ConfigValidator().validate(config)
if( NF.getSyntaxParserVersion() == 'v2' )
new ConfigValidator().validate(config)

// -- create a new runner instance
final runner = new ScriptRunner(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package nextflow.config

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.NF
import nextflow.config.schema.ConfigScope
import nextflow.config.schema.SchemaNode
import nextflow.config.schema.ScopeName
Expand Down Expand Up @@ -74,14 +73,10 @@ class ConfigValidator {
}

void validate(ConfigMap config) {
if( NF.getSyntaxParserVersion() != 'v2' )
return
validate(config.toConfigObject())
}

void validate(ConfigObject config) {
if( NF.getSyntaxParserVersion() != 'v2' )
return
final flatConfig = config.flatten()
for( String key : flatConfig.keySet() ) {
final names = key.tokenize('.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package nextflow.config

import nextflow.SysEnv
import org.junit.Rule
import spock.lang.Specification
import test.OutputCapture
Expand All @@ -29,14 +28,6 @@ class ConfigValidatorTest extends Specification {
@Rule
OutputCapture capture = new OutputCapture()

def setupSpec() {
SysEnv.push(NXF_SYNTAX_PARSER: 'v2')
}

def cleanupSpec() {
SysEnv.pop()
}

def 'should warn about invalid config options' () {
given:
def config = new ConfigMap([
Expand Down