Skip to content

Fixes validator crash on NaN summary size for symlinked datasets - #443

Open
brainy-joseph wants to merge 7 commits into
bids-standard:mainfrom
brainy-joseph:main
Open

Fixes validator crash on NaN summary size for symlinked datasets#443
brainy-joseph wants to merge 7 commits into
bids-standard:mainfrom
brainy-joseph:main

Conversation

@brainy-joseph

Copy link
Copy Markdown

Prevent crash described in Issue #411

When a dataset contains symlinks, summary.size can be NaN, and prettyBytes (from @std/fmt/bytes) throws "TypeError: Expected a finite number, got number: NaN", crashing the validator at its summary step.

This guards the value with Number.isFinite, falling back to 0 so the summary always renders. Display only change and has no validation logic touched. Thank you! :D

@effigies

Copy link
Copy Markdown
Contributor

I think we probably want to fix this by avoiding adding nan to the summary size in the first place, not detecting it at the end. Then we at least still get the size of the resolvable files.

I'm guessing the nan happens on broken symlinks, not just any symlink?

Refactor file size accumulation to check for finite values.
@brainy-joseph

Copy link
Copy Markdown
Author

I think we probably want to fix this by avoiding adding nan to the summary size in the first place, not detecting it at the end. Then we at least still get the size of the resolvable files.

I'm guessing the nan happens on broken symlinks, not just any symlink?

Hi @effigies , I have now updated the PR to fix this at the source!

I reverted the display only update in ⁠output.ts⁠ and instead added a ⁠Number.isFinite⁠ check in ⁠src/summary/summary.ts⁠ where the size is accumulated. This way, valid file sizes are still counted but NaN values from broken symlinks are skipped.

Let me know if this looks good!

@brainy-joseph

Copy link
Copy Markdown
Author

pre-commit.ci autofix

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.74%. Comparing base (4b83dc9) to head (3ec05fc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #443   +/-   ##
=======================================
  Coverage   87.73%   87.74%           
=======================================
  Files          65       65           
  Lines        4843     4846    +3     
  Branches      789      789           
=======================================
+ Hits         4249     4252    +3     
  Misses        502      502           
  Partials       92       92           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@effigies effigies left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a small change log entry? See the contributing guide for how to use scriv.

@brainy-joseph

Copy link
Copy Markdown
Author

Could you add a small change log entry? See the contributing guide for how to use scriv.

@effigies Read the Contribution Guide and added the changelog entry manually via GitHub as I am currently out of my city. I hope that was what you were looking for. Let me know if any changes are needed! :)

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.

2 participants