Project export ratelimit has wrong Ratelimit-Reset
and no Retry-After
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Ratelimit for project export has wrong RateLimit-Reset:
and does not include Retry-After:
header in 429 Too Many Requests
response.
Steps to reproduce
for i in 1 2; do curl -i -H "Authorization: Bearer ${TOKEN}" https://gitlab.com/api/v4/projects/"${PROJECT}"/export; done
Example Project
N/A (any project)
What is the current bug behavior?
- There is no
Retry-After:
header:
HTTP/1.1 429 Too Many Requests
Server: nginx
Date: Thu, 30 Jan 2020 14:14:16 GMT
Content-Type: application/json
Content-Length: 89
Cache-Control: no-cache
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: tS3lOyzMeF4
X-Runtime: 0.039384
RateLimit-Limit: 600
RateLimit-Observed: 5
RateLimit-Remaining: 595
RateLimit-Reset: 1580393717
RateLimit-ResetTime: Thu, 30 Jan 2020 14:15:17 GMT
GitLab-LB: fe-15-lb-gprd
GitLab-SV: localhost
{"message":{"error":"This endpoint has been requested too many times. Try again later."}}
-
RateLimit-Reset{,Time}:
is wrong (it points 60 s into the future, it should be 300 s according to https://docs.gitlab.com/ee/user/project/settings/import_export.html#rate-limits). -
There is no
Retry-After
What is the expected correct behavior?
RateLimit-Reset: <now() + remaining time>
RateLimit-ResetTime: <same>
Retry-After: <remaining time>
Relevant logs and/or screenshots
See bug behaviour above.
Also traceback from python-gitlab-1.6.0 (Debian 10):
Traceback (most recent call last):
File "./export.py", line 33, in <module>
main()
File "./export.py", line 21, in main
export = project.exports.create({})
File "/usr/lib/python3/dist-packages/gitlab/exceptions.py", line 246, in wrapped_f
return f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gitlab/mixins.py", line 204, in create
**kwargs)
File "/usr/lib/python3/dist-packages/gitlab/__init__.py", line 600, in http_post
post_data=post_data, files=files, **kwargs)
File "/usr/lib/python3/dist-packages/gitlab/__init__.py", line 489, in http_request
wait_time = int(result.headers["Retry-After"])
File "/usr/lib/python3/dist-packages/requests/structures.py", line 52, in __getitem__
return self._store[key.lower()][1]
KeyError: 'retry-after'
Output of checks
This bug happens on GitLab.com
Possible fixes
This most likely originated in commit 091b6a8a. I don't know how to fix.
Edited by 🤖 GitLab Bot 🤖