Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

hfile_s3: reading to EOF fails with EINVAL when object size is a multiple of the read part size

Closed Beginner friendly
#2,097 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@PeterDowdy is already working on this.

Since Oct 1, 2026.

  • #2098 by @PeterDowdy — open
  • #2099 by @Tyagiquamar — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
aws, c
Domain
cloud

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

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.