brentp / vcfanno

annotate a VCF with other VCFs/BEDs/tabixed files
https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-0973-5
MIT License
357 stars 55 forks source link

Failures exit with error code 0 #143

Closed lbeltrame closed 3 years ago

lbeltrame commented 3 years ago

I had a malformed configuration file, which included more ops than names in its contents (provided below). As expected, vcfanno failed. The problem is that while it failed, it exited with error code 0, which is interpreted as success pipelines, workflows, etc.

As it was part of a workflow, it proceeded to the next step as the failure was interpreted as success.

This isn't specific to a bad configuration, or a user error. Any command, success or not, returns error code 0:

(lbeltrame) lbeltrame@vmhpc14:~$ /home/share/bcbio/anaconda/bin/vcfanno

=============================================
vcfanno version 0.3.2 [built with go1.12.1]

see: https://github.com/brentp/vcfanno
=============================================
Usage:
/home/share/bcbio/anaconda/bin/vcfanno config.toml input.vcf > annotated.vcf

  -base-path string
        optional base-path to prepend to annotation files in the config
  -ends
        annotate the start and end as well as the interval itself.
  -lua string
        optional path to a file containing custom javascript functions to be used as ops
  -p int
        number of processes to use. (default 2)
  -permissive-overlap
        annotate with an overlapping variant even it doesn't share the same ref and alt alleles. Default is to require exact match between variants.
(lbeltrame) lbeltrame@vmhpc14:~$ echo $?
0

For a comparison, common programs like those in GNU return all but 0 in case of anything that's not success.

Observed result: Exit code of 0 regardless of the final state of the program (error, success)

Expected result: Exit code != 0 in case of errors.

brentp commented 3 years ago

I see what you mean about sending no arguments. I have a local fix for that. but I can not recreate when there's a problem with the config. Using files in the vcfanno repo and this conf (diff.toml):

[[annotation]]
file="tmp_annotation.txt.gz"
columns = [9, 10, 11]
names=["REF_60", "HET_60", "XXX"]
ops=["first", "first"]

I run:

vcfanno -base-path tests/ref-alt-test/ ./diff.toml tests/ref-alt-test/tmp_calls.vcf.gz > x.vcf

and see:


=============================================
vcfanno version 0.3.3 [built with go1.16.5]

see: https://github.com/brentp/vcfanno
=============================================
vcfanno.go:92: CheckAnno err:must specify same # of 'columns' as 'ops' for tmp_annotation.txt.gz
$ echo $?
1

so it has exit code 1. Can you show how to recreate the problem with a bad conf?

lbeltrame commented 3 years ago

Hmm, it looks like you're right. If that's the case, the problem I thought it was in vcfanno is somewhere else. I'll leave the issue open for the usage/help scenario which is a real bug.

EDIT: I think I found the actual source of the problem and it was outside vcfanno (error code was correct, but it was gobbled up during the processing), so this can be closed.