Skip to content

FIX: Don't crash on non-string BIDS filter values - #3641

Merged
effigies merged 1 commit into
nipreps:masterfrom
lobennett:fix/bids-filter-non-string-values
Apr 26, 2026
Merged

FIX: Don't crash on non-string BIDS filter values#3641
effigies merged 1 commit into
nipreps:masterfrom
lobennett:fix/bids-filter-non-string-values

Conversation

@lobennett

Copy link
Copy Markdown
Contributor

Closes #3394.

Changes proposed in this pull request

  • Replace not isinstance(value, Query) with isinstance(value, str) in _process_value (fmriprep/config.py, called during --bids-filter-file unserialization).

Why

_process_value was checking 'Query' in value for any non-Query input, which raised TypeError: argument of type 'int' is not iterable whenever a filter value was an int or float (e.g. {"inv": 2} in the JSON filter file). Using isinstance(value, str) as the guard skips the substring check for non-string scalars, so they pass through unchanged.

The Query-passthrough behavior previously provided by not isinstance(value, Query) is preserved naturally: Query enum members are not instances of str, so the guard short-circuits and the value is returned unchanged.

Testing

  • Verified the fixed conditional locally against int, float, bool, plain strings, lists with mixed scalar types, repr(Query.OPTIONAL) (the existing Query-repr unserialize path), and existing Query instances. All pass through or unserialize as expected.
  • ruff check, ruff format --check, and codespell pass on the modified file.

Documentation that should be reviewed

None.

Replace 'not isinstance(value, Query)' with 'isinstance(value, str)' in
the bids-filter unserialize step. The previous condition reached
'Query' in value for any non-Query input, which raised TypeError for
ints and floats (e.g. {"inv": 2} in a --bids-filter-file).

Closes niprepsgh-3394.
@welcome

welcome Bot commented Apr 25, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! It looks like this is your first time contributing to fMRIPrep. 😄
We invite you to list yourself as an fMRIPrep contributor. To learn more about what that entails and how we credit our contributors, please check out the contributing guidelines. If your name is not already on the list, please insert it, in alphabetical order, into the CONTRIBUTORS.md file.
Of course, if you want to opt-out this time there is no problem at all with adding your name later. You will be always welcome to add it in the future whenever you feel it should be listed.

@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.57%. Comparing base (acdb0fd) to head (64ee747).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3641   +/-   ##
=======================================
  Coverage   74.57%   74.57%           
=======================================
  Files          62       62           
  Lines        4975     4975           
  Branches      637      637           
=======================================
  Hits         3710     3710           
  Misses       1131     1131           
  Partials      134      134           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@effigies
effigies merged commit 4e94880 into nipreps:master Apr 26, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loading of bids-filter-file crash on integer/float values

2 participants