vcf/bcf reading has no concept of errors!

Open
#246 9 comments 0 reactions 1 assignee View on GitHub

@jkbonfield is already working on this.

Since May 29, 2018.

Assessment

This issue has not been assessed yet.

Description

breaks-ABI D2: Moderate P2: Desirable

zlib can spot truncated files, as can bgzf, but the code for bcf_read glosses over all such things and treats any error as EOF.

Note this isn't the same issues as https://github.com/samtools/samtools/issues/101 which is describing the samtools application as ignoring errors returned by htslib. This is htslib not being able to return the error in the first place.

It can be demonstrated in bcftools or htsfile, but the error comes from bcf_read returning 0 in many cases.

$ samtools mpileup -g ../samtools/test/mpileup/mpileup.1.bam > /tmp/_.bcf
$ head -50000c /tmp/_.bcf | ./htsfile -c - > /dev/null;echo $?
ret=0
0
$ head -50000c /tmp/_.bcf | zcat > /dev/null;echo $?

gzip: stdin: unexpected end of file
1

The ret=0 is debugging I put into htsfile to show the return value from the last bcf_read() call.

Dominant language
C
Stars
950
Forks
475
Avg merge
3d 13h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

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 samtools/htslib

All issues in samtools/htslib

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.