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

NEW
Unassigned

Status

Tree Management
Treeherder: API
P3
normal
2 years ago
a year ago

People

(Reporter: emorley, Unassigned)

Tracking

Details

(Reporter)

Description

2 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

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

Updated

a year ago
Depends on: 1203551, 1221485
You need to log in before you can comment on or make changes to this bug.