Skip to content

Fix dropped bytes in short range reads - #480

Merged
mattjala merged 1 commit into
masterfrom
fix/short-range-read-zero-fill
Oct 2, 2026
Merged

mattjala merged 1 commit into
masterfrom
fix/short-range-read-zero-fill

Conversation

@mattjala

@mattjala mattjala commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

When a range read returns fewer bytes than requested, getStorBytes pads the result to the requested length. The padding line was missing its assignment (buffer[:(len(data))] instead of
buffer[:len(data)] = data), so it returned a zero buffer and discarded everything that was read, and returned success.

A read now comes back short when it runs past the end of the object, as with an H5D_CONTIGUOUS_REF dataset whose last chunk extends past the end of its file. HSDS 1.0.x reads each contiguous reference as one chunk sized to its data, so it rarely hits this today, but it will once h5json splits those datasets into virtual chunks again (see HDFGroup/hdf5-json#380).

This needs to ship before or with that h5json version bump on HSDS's side.

When a range read returns fewer bytes than requested, getStorBytes pads
the result to the requested length. The padding line was missing its
assignment (`buffer[:(len(data))]` instead of
`buffer[:len(data)] = data`), so it returned a zero buffer and discarded
everything that was read, and returned success.

A read now comes back short when it runs past the end of the object, as with
an H5D_CONTIGUOUS_REF dataset whose last chunk extends past the end of
its file. HSDS 1.0.x reads each contiguous reference as one chunk sized
to its data, so it rarely hits this today, but it will once h5json
splits those datasets into virtual chunks again (see HDFGroup/hdf5-json#380).

This needs to ship before or with that h5json version bump on HSDS's side.
@mattjala
mattjala force-pushed the fix/short-range-read-zero-fill branch from 89655e3 to 9cd3ecc Compare October 2, 2026 17:27
@mattjala
mattjala merged commit c423bab into master Oct 2, 2026
55 of 56 checks passed
@mattjala
mattjala deleted the fix/short-range-read-zero-fill branch October 2, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant