Skip to content

Panic: slice bounds out of range [9:8] when processing VCF files without FORMAT/sample columns #13

@Lupphes

Description

@Lupphes

svync crashes with a panic when processing VCF files that have only 8 columns (no FORMAT or sample columns). This is valid VCF format for files without genotype information, but svync assumes all VCF files have at least 9 columns.

Error

panic: runtime error: slice bounds out of range [9:8]

goroutine 1 [running]:
github.com/nvnieuwk/svync/svync_api.(*Header).parse(0xc0001e9a40, {0xc000154a80, 0x26})
	/github/workspace/svync_api/execute.go:246 +0x9b8
github.com/nvnieuwk/svync/svync_api.parseLine({0xc000154a80?, 0x26?}, 0x1b6?, 0x0?, 0x46f8f9?, 0xc0000f19e8?, 0x199?, 0x58799c?, 0x19?, 0xc0009b3980)
	/github/workspace/svync_api/execute.go:136 +0xdd
github.com/nvnieuwk/svync/svync_api.Execute(0xc0000ae580, 0xc0000ae940)
	/github/workspace/svync_api/execute.go:76 +0x5de

Root Cause

In svync_api/execute.go at line 246, the code attempts to extract sample names:

header.Samples = strings.Split(line, "\t")[9:]

When the VCF header has only 8 columns (indices 0-7), attempting to slice from index 9 causes the panic.

Reproduction

Test File

The issue occurs with Manta's candidate SV files (candidate_sv.vcf and candidate_small_indels.vcf), which have this header:

#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO

Only 8 columns - missing FORMAT (column 9) and sample columns (10+).

Steps to Reproduce

  1. Download the test file: manta_candidate_8col.vcf.gz

  2. Run svync:

svync -c manta.yaml -i manta_candidate_8col.vcf.gz -o output.vcf
  1. Observe the panic

Expected Behavior

svync should handle VCF files with 8 columns gracefully, either by:

  • Processing them with an empty samples list
  • Providing a clear error message about missing FORMAT/sample columns
  • Skipping sample-related processing when no samples are present

Suggested Fix

parts := strings.Split(line, "\t")
if len(parts) > 9 {
    header.Samples = parts[9:]
} else {
    header.Samples = []string{} // No samples in this VCF
}

Environment

  • svync version: 0.3.0 (0.2.0)
  • Input: Manta candidate SV VCF (8 columns)
  • Config: manta.yaml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions