#2461 closed defect (fixed)

IReadable.read should document out-of-range errors

Reported by: daira Owned by: daira
Priority: normal Milestone: 1.10.2
Component: documentation Version: 1.10.1
Keywords: interfaces docs Cc:
Launchpad Bug:

Description

In interfaces.py, document error behaviour when offset and/or size are outside the bounds of the file.

Change History (6)

comment:1 Changed at 2015-07-17T21:53:53Z by daira

  • Milestone changed from 1.11.0 to 1.10.2

comment:2 follow-up: Changed at 2015-07-21T18:18:46Z by zooko

I think the behavior ought to be to return a short result, i.e. return as many bytes as *do* exist and fall within the requested range, and return the 0-length string if none do. That way clients can issue range read requests without knowing for sure whether the request will start past the end or cross the end, which can allow them to do fewer round trips, maybe, in some cases.

comment:3 in reply to: ↑ 2 Changed at 2015-07-25T00:29:38Z by daira

Replying to zooko:

I think the behavior ought to be to return a short result, i.e. return as many bytes as *do* exist and fall within the requested range, and return the 0-length string if none do. That way clients can issue range read requests without knowing for sure whether the request will start past the end or cross the end, which can allow them to do fewer round trips, maybe, in some cases.

That's a self-consistent design, but it is not the current design (which is for the web-API to truncate the request as necessary to satisfy HTTP semantics). No extra round trips are ever needed, because the file length is known at the time the web-API makes the read call. Also the design change you suggest is not needed to fix #2459, the bug that motivated this ticket. I am skeptical about doing anything more than necessary to fix that bug in a point release.

Last edited at 2015-07-25T00:30:43Z by daira (previous) (diff)

comment:4 Changed at 2015-07-28T20:05:06Z by warner

I'll update it to express the current behavior: reject out-of-range reads, permit zero-length reads.

The webapi continues to allow arbitrary oversized Range: headers, since web/filenode.py clips these to the filesize before calling read(). It's just internal callers who must meet the no-overrun requirement (and they can always read the whole file, offset=0 size=None, without paying attention to get_size() ahead of time).

comment:5 Changed at 2015-07-28T20:09:26Z by warner

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [6252a72]

comment:6 Changed at 2015-07-28T21:52:06Z by daira

Reviewed, +1.

Note: See TracTickets for help on using tickets.