Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -39,7 +39,13 @@ class FormatDirectoryPathEvaluator implements Evaluator {
if (file instanceof List) {
return Evaluator.Result.failure("'${value}' is not a directory, but a file path pattern" as String)
}
if (file.exists() && !file.isDirectory()) {

// Check if this is an Azure storage path
def String scheme = file.scheme
def boolean isAzurePath = scheme == 'az'

// For Azure paths, skip the directory check as Azure blob storage doesn't have true directories
if (!isAzurePath && file.exists() && !file.isDirectory()) {
return Evaluator.Result.failure("'${value}' is not a directory, but a file" as String)
}
return Evaluator.Result.success()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ class FormatFilePathEvaluator implements Evaluator {
if (file instanceof List) {
return Evaluator.Result.failure("'${value}' is not a file, but a file path pattern" as String)
}
if (file.exists() && file.isDirectory()) {

// Check if this is an Azure storage path
def String scheme = file.scheme
def boolean isAzurePath = scheme == 'az'

// For Azure paths, skip the directory check as Azure blob storage doesn't have true directories
if (!isAzurePath && file.exists() && file.isDirectory()) {
return Evaluator.Result.failure("'${value}' is not a file, but a directory" as String)
}
return Evaluator.Result.success()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class FormatFilePathPatternEvaluator implements Evaluator {
return Evaluator.Result.failure("No files were found using the glob pattern '${value}'" as String)
}
files.each { file ->
if (file.isDirectory()) {
// Check if this is an Azure storage path
def String scheme = file.scheme
def boolean isAzurePath = scheme == 'az'

// For Azure paths, skip the directory check as Azure blob storage doesn't have true directories
if (!isAzurePath && file.isDirectory()) {
errors.add("'${file.toString()}' is not a file, but a directory" as String)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ class SchemaEvaluator implements Evaluator {

// Actual validation logic
def Path file = Nextflow.file(value)
// Don't validate if the file does not exist or is a directory
if(!file.exists() || file.isDirectory()) {
log.debug("Could not validate the file ${file.toString()}")

// Check if this is an Azure storage path
def String scheme = file.scheme
def boolean isAzurePath = scheme == 'az'

// For non-Azure paths, skip validation if it's a directory
if(!isAzurePath && file.exists() && file.isDirectory()) {
log.debug("Could not validate the file ${file.toString()} - path is a directory")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Azure Path Validation Skips Files

The condition if(file.isDirectory() || value.startsWith('az://')) skips schema validation for all Azure paths, including files. This contradicts the goal of validating Azure file paths and only skipping validation for directories. Additionally, the log message "path is a directory" is misleading when an Azure file path triggers this condition.

Fix in Cursor Fix in Web

return Evaluator.Result.success()
}

Expand Down
24 changes: 24 additions & 0 deletions src/test/groovy/nextflow/validation/ValidateParametersTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1397,4 +1397,28 @@ class ValidateParametersTest extends Dsl2Spec{
noExceptionThrown()
stdout == ["* --testing: test", "* --genomebutlonger: true"]
}

def 'should validate Azure storage file paths' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_azure_path.json').toAbsolutePath().toString()
def SCRIPT = """
params.az_file = 'az://mycontainer/myfile.txt'
params.az_directory = 'az://mycontainer/mydir/'
include { validateParameters } from 'plugin/nf-schema'

validateParameters(parameters_schema: '$schema')
"""

when:
def config = [:]
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
}
}
Loading