hfile_s3: reading to EOF fails with EINVAL when object size is a multiple of the read part size
Maintainers usually reply within 3 days
@PeterDowdy is already working on this.
Since Oct 1, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start by locating the hfile_s3 implementation and reading s3_read() alongside http_status_errno(), then reproduce the failure with the aligned.bin commands in the issue. The work is done when reading an S3 object whose size is an exact multiple of the read part size reaches EOF successfully instead of returning EINVAL.
Written by the indexing model from the issue text.
Description
Reading an S3 object to EOF fails with EINVAL when its size is an exact multiple of the read part size (1 MiB by default), even though all the data has already been delivered.
s3_read() only treats a part as the last one when it is shorter than part_size. If the object size is an exact multiple, the final part is full-sized, so s3_read() requests another range starting exactly at EOF. S3 answers that with HTTP 416. http_status_errno() has no case for 416 and returns EINVAL by default, so the read fails.
Reproduce:
head -c 1048576 /dev/zero > aligned.bin
htsfile -C aligned.bin s3://bucket/aligned.bin # upload works
htsfile -C s3://bucket/aligned.bin out.bin # fails with EINVAL
- Dominant language
- C
- Stars
- 954
- Forks
- 475
- Avg merge
- 5d 12h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from samtools/htslib
-
Difficulty 3/5 Half a day Newbie friendliness 55/100
Maintainers usually reply within 3 days
-
CI testing for signed-off-by commitsMay be free again @jkbonfield claimed this 151 days ago, and no pull request is open. Open
samtools/htslib#2014 · 1 assignee ·
Maintainers usually reply within 3 days
-
Suggestion: populate INFO name in warning "INFO tag id=146"May be free again @daviesrob claimed this 172 days ago, and no pull request is open. Open
samtools/htslib#1996 · 4 comments · 1 assignee ·
Maintainers usually reply within 3 days
-
tabix performanceMay be free again @daviesrob claimed this 410 days ago, and no pull request is open. Open
samtools/htslib#1949 · 1 comment · 1 assignee ·
Maintainers usually reply within 3 days
-
hts_idx_t file query APIMay be free again @jkbonfield claimed this 564 days ago, and no pull request is open. Open
samtools/htslib#1902 · 4 comments · 1 assignee ·
Maintainers usually reply within 3 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FujiNetWIFI/fujinet-firmware#2079 ·
Maintainers usually reply within 1 day
-
bug Official Image release/25.12 Supported Device target/kirkwood
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area/archive bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
DarkFlippers/qUnleashed#374 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 84/100
VirusTotal/yara#2255 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100