Skip to content

Commit

Permalink
Fix 404 error parsing of top/25 API answer
Browse files Browse the repository at this point in the history
In the JSON returned by the API, "errors" is an array, not an object: this lead to a failed assert in the d["errors"].HasMember() call.
  • Loading branch information
leovilok authored Mar 14, 2021
1 parent 0bf3098 commit eb058ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Etterna/Singletons/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2019,8 +2019,9 @@ DownloadManager::RefreshTop25(Skillset ss)
auto done = [ss](HTTPRequest& req, CURLMsg*) {
Document d;
if (d.Parse(req.result.c_str()).HasParseError() ||
(d.HasMember("errors") && d["errors"].HasMember("status") &&
d["errors"]["status"].GetInt() == 404) ||
(d.HasMember("errors") && d["errors"].IsArray() &&
d["errors"][0].HasMember("status") &&
d["errors"][0]["status"].GetInt() == 404) ||
!d.HasMember("data") || !d["data"].IsArray()) {
Locator::getLogger()->trace(
"Malformed top25 scores request response: {}", req.result);
Expand Down

0 comments on commit eb058ff

Please sign in to comment.