Bug: `nf-core pipelines lint` mishandles defaults for nullable numeric parameters

Open Beginner friendly
#4,636 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
tooling

Research direction

Start at PipelineSchema.sanitise_param_default(), where the code compares param["type"] == "number" and otherwise coerces the default to str; a list type such as ["number", "null"] falls into the string branch. Rework the check so any type list containing number keeps a numeric default while null remains valid, then rerun nf-core pipelines lint --key schema_lint plus the pipeline schema unit tests. Done means the 400 default is reported as valid and non-numeric defaults still fail as before.

Written by the indexing model from the issue text.

Description

bug schema
Description of the bug

Given this schema parameter:

{
  "type": ["number", "null"],
  "default": 400
}

Running:
nf-core pipelines lint --key schema_lint
fails with:
Default parameters are invalid: '400' is not of type 'number', 'null'

The issue appears to be in PipelineSchema.sanitise_param_default():

if param["type"] == "number":
    param["default"] = float(param["default"])
    return param

param["default"] = str(param["default"])

For ["number", "null"], the type comparison fails and the numeric default is converted to the string "400". This then fails JSON Schema validation.

Expected behavior: nullable numeric types should retain numeric defaults, e.g. 400, while still accepting null.

Command used and terminal output

System information

nf-core/tools version: 4.2.2

Dominant language
Python
Stars
333
Forks
273
Avg merge
1d 18h
Merged PRs (30d)
51

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nf-core/tools

All issues in nf-core/tools

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.