COPR currently returns funny HTTP error codes like:
500 Invalid request
on lack of permissions for selected copr and more. Most of the time, 500 is returned even on client side errors and it's not easy to tell what went wrong.
It would be nice if error responses conatined correct HTTP error code - 4xx for client errors and 5xx for server errors so that error handling/reporting is easier in applications using COPR API.
Thanks, I'll have a look at that
We apologize, that this took years, but it is finally done. Meanwhile, both APIv1 (aka Legacy API) and APIv2 (aka REST-like API) are deprecated, so this was implemented in new APIv3. See this example code
from copr.v3 import Client, CoprRequestException
client = Client.create_from_config_file()
client.config["login"] = None # So we can't authorize
url = "http://foo.bar/baz.src.rpm"
client.build_proxy.create_from_url("@copr", "foo", url)
except CoprRequestException as ex:
Login invalid/expired. Please visit http://localhost:5000/api to get or renew your API token.
Please see the Debugging section in the documentation - https://python-copr.readthedocs.io/en/latest/client_v3/error_handling.html#debugging
There are also described status codes that you can expect, but it was not released yet - https://pagure.io/copr/copr/pull-request/392#request_diff
A package fixing this issue has been deployed to the production instance.
Also, the list of status codes is now in the documentation - https://python-copr.readthedocs.io/en/latest/client_v3/error_handling.html#status-codes