Open
Conversation
| readJsonFile(path, configVars, result) | ||
| else if( type == 'yml' || type == 'yaml' ) | ||
| readYamlFile(path, configVars, result) | ||
| for( String paramFile: file.split(',') ) { |
There was a problem hiding this comment.
Bug: The comma-separated string for --params-file is split using split(',') without trimming whitespace or filtering empty strings, causing errors for common inputs like "file1.json, file2.yaml".
Severity: MEDIUM
Suggested Fix
Modify the string parsing to handle whitespace and empty strings gracefully. Instead of file.split(','), use a more robust method like file.tokenize(',').collect { it.trim() }.findAll { it }. This will split the string, trim whitespace from each resulting path, and remove any empty entries before processing, aligning with existing patterns in the codebase for handling comma-separated values.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy#L690
Potential issue: The code at line 690 splits the `--params-file` string by commas using
`file.split(',')`. This method does not trim whitespace from the resulting file paths.
If a user provides a list with spaces after commas (e.g., `"file1.json, file2.yaml"`),
the subsequent call to `FileHelper.asPath()` will receive a path with a leading space
(e.g., `" file2.yaml"`) and throw an `IllegalArgumentException`. Similarly, trailing or
consecutive commas will produce empty strings, also causing an exception. This deviates
from the established pattern in the codebase for parsing comma-separated lists, which
typically involves trimming and filtering empty entries.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the handling of multiple parameter files in the
CmdRuncommand. Now, users can specify a comma-separated list of parameter files, and each will be processed in sequence.Parameter file handling improvements:
CmdRunso that if the--params-fileoption contains multiple files separated by commas, each file is validated and loaded individually, supporting both JSON and YAML formats.