Skip to content

API: Fix FileRange validation order#15929

Open
aviralgarg05 wants to merge 1 commit intoapache:mainfrom
aviralgarg05:aviralgarg/issue-15922-file-range-validation-order
Open

API: Fix FileRange validation order#15929
aviralgarg05 wants to merge 1 commit intoapache:mainfrom
aviralgarg05:aviralgarg/issue-15922-file-range-validation-order

Conversation

@aviralgarg05
Copy link
Copy Markdown

@aviralgarg05 aviralgarg05 commented Apr 10, 2026

Fixes #15922

Summary

Fix FileRange constructor validation so negative offset and length values are rejected before the fields are assigned.

Previously, the constructor validated length() and offset() before assigning the constructor arguments to the fields. That meant the checks were reading the default field values instead of the incoming arguments, allowing malformed ranges with negative values to be created.

Changes

  • validate the constructor arguments directly in FileRange
  • add regression tests covering negative length
  • add regression tests covering negative offset

Why this matters

Invalid FileRange instances can propagate into vectored reads and fail later at runtime. Rejecting bad inputs at construction time keeps the API behavior correct and surfaces the error at the actual boundary where the bad state is introduced.

Testing

  • ./gradlew :iceberg-api:test
  • ./gradlew :iceberg-api:spotlessCheck

@github-actions github-actions bot added the API label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: Fix FileRange validation order to reject negative offset/length

1 participant