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

RESOLVED WORKSFORME

Status

P3
normal
RESOLVED WORKSFORME
4 years ago
9 months ago

People

(Reporter: emorley, Unassigned)

Tracking

Details

(Reporter)

Description

4 years ago
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.
(Reporter)

Comment 1

4 years ago
s/len(job)/len(job_chunk)/ that is.
(Reporter)

Updated

3 years ago
Depends on: 1203551, 1221485
(Reporter)

Comment 2

9 months ago
This was fixed in another bug
Status: NEW → RESOLVED
Last Resolved: 9 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.