From 3da77052de881fedef9c742e1d2a97866713846c Mon Sep 17 00:00:00 2001 From: Taksh Date: Mon, 20 Apr 2026 10:47:23 +0530 Subject: [PATCH] Fix find_offset treating exact start-boundary as 'not found' scripts/find_offset.py treats each metadata row as the half-open interval [start, end). After the bisect + 'not exact match' decrement, loc points at the row whose start is <= offset, so the validity check is: if data.iloc[loc].start >= offset or data.iloc[loc].end <= offset: raise ValueError(f"Offset {offset} not found in {opts.file}.") The left side uses >= instead of >. When the requested offset lands exactly on a row boundary (offset == start) that row is actually the correct one -- the first byte of the document begins at start -- but the check raises ValueError and aborts before locs.append(loc). Using > matches the half-open semantics (offset in [start, end)) and keeps the 'offset >= end' side unchanged, so the only behaviour change is that offsets exactly on a start boundary are now correctly reported as found instead of failing. --- scripts/find_offset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/find_offset.py b/scripts/find_offset.py index eda8a96f..dcfcb4bb 100644 --- a/scripts/find_offset.py +++ b/scripts/find_offset.py @@ -36,7 +36,7 @@ def main() -> None: # in case of not exact match loc -= 1 - if data.iloc[loc].start >= offset or data.iloc[loc].end <= offset: + if data.iloc[loc].start > offset or data.iloc[loc].end <= offset: raise ValueError(f"Offset {offset} not found in {opts.file}.") locs.append(loc)