Skip to content

Make sure we set `siafile.numChunks`. Otherwise we get a NaN later on.

Ivaylo Novakov requested to merge ivo/fix_NaN_NDF into master

MERGE REQUEST

MR Guidelines

Overview

An error that surfaced during JSON parsing was actually caused by a division by zero. The zero came from a size calculation which used a manually constructed SiaFile struct where we had forgotten to set the numChunks field. I am not sure how we can protect ourselves against something like that in the future - go doesn't post-construction hooks where we can run a validator, so we can't save people from themselves when they construct their structs by hand. I've added more verbose logging to the JSON parsing bit which surfaces the problem, so we'd be able to catch future problems there as well.

Example for Visual Changes

Checklist

Review and complete the checklist to ensure that the MR is complete before assigned to an approver.~~

  • [ ] All new methods or updated methods have clear docstrings
  • [ ] Testing added or updated for new methods
  • [ ] Any new packages are added to Makefile and .gitlab-ci.yml
  • [ ] API documentation updated for API updates
  • [ ] Module README.md updated for changes to workflow
  • [ ] Issue added to Sia-UI repo for new supporting features
  • [ ] Changelog File Created

Issues Closed

Closes: #4137 (closed)

Edited by Ivaylo Novakov

Merge request reports

Loading