Open cocoon333 opened 1 year ago
The error generally occurs in clusters though, so possibly caused by network problems?
Most likely the osu! API being flaky returning errors in plaintext. Unsure if it's worth adding a mimetype check before decoding to JSON to avoid uncaught exceptions?
I haven't seen this error before, which makes me think it's async-specific. On inspecting source code it seems that requests and aiohttp differ in how they handle json decoding: requests decodes regardless of mimetype (making appropriate guesses), and aiohttp throws by default.
It is possible the returned value here is a plaintext error, but it's also possible it's a normal json response with a differing mimetype. Even if this is an osu-web issue, I'd prefer to match sync behavior in all possible cases.
I've disabled throw-on-invalid-mimetype in cf56b0bd2e048027701da353d73dea347e15d405 in the hopes that fixes this. Please reopen if it doesn't.
Unfortunately, the same error is still coming up.
Hmm. Was really hoping that would be the issue. I'd need to see the actual response to figure out what to do here. If you're hammering the api, it's possible you're hitting a ratelimit response that I've never seen before.
Screenshot of more detailed error message
As an update, I hammered the api until I got a ratelimit error and can confirm it's returned as valid json:
...
File "/Users/tybug/Desktop/Liam/coding/osu/ossapi/ossapi/ossapiv2_async.py", line 2428, in user
return await self._get(User, f"/users/{user}/{mode.value if mode else ''}",
File "/Users/tybug/Desktop/Liam/coding/osu/ossapi/ossapi/ossapiv2_async.py", line 637, in _get
return await self._request(type_, "GET", url, params=params)
File "/Users/tybug/Desktop/Liam/coding/osu/ossapi/ossapi/ossapiv2_async.py", line 624, in _request
self._check_response(json_, url)
File "/Users/tybug/Desktop/Liam/coding/osu/ossapi/ossapi/ossapiv2_async.py", line 633, in _check_response
raise ValueError(f"api returned an error of `{json_['error']}` for "
ValueError: api returned an error of `Too Many Attempts.` for a request to https://osu.ppy.sh/api/v2/users/tybug2/
So that's not the culprit above.
Unfortunately, I cannot reproduce this error. It just happens once in a while when I am requesting user profiles.