If a templateflow image download fails, the truncated file is non-zero and considered as fetched and returned in subsequent queries.
This occurred in a rare case where the truncated image silently propagated through Ants-based resampling and subsequent brain extraction, corrupting the whole pipeline.
nipreps/fmriprep#2192
It seems that it was using the default non-datalad download.
An option would be to checksum-validate each time the template is queried.