Closed Bug 1190477 Opened 9 years ago Closed 6 years ago

API requests with a 'count' higher than the limit, should fail more obviously

Categories

(Tree Management :: Treeherder: API, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: emorley, Unassigned)

References

Details

We currently cap the 'count' param passed to the API for things like the jobs endpoint, eg:
https://github.com/mozilla/treeherder/blob/f9d2efddb8d778cf8cdd9c5a5dfd34d6e9f42416/treeherder/webapp/api/jobs.py#L70

However we do so transparently, which could cause buggy behaviour, eg to handle the pagination, consumers of our API will likely do things like:

```
CHUNK_SIZE = 3000

while True:
    jobs_chunk = fetch_jobs(count=CHUNK_SIZE)
    if len(job) < CHUNK_SIZE:
        break
    jobs.append(jobs_chunk)
```

However they'll break after the first iteration, since they'll only get 2000 jobs back.

We should make the request fail with an HTTP 400 or similar.

At the same time, it would be good to double check all endpoints have a max count of items returned.
s/len(job)/len(job_chunk)/ that is.
Depends on: 1203551, 1221485
This was fixed in another bug
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.