Announcements

Help Wizard

Step 1

NEXT STEP

Web API 502 Bad Gateway for top items endpoints when offset and limit exceed total

Solved!

Web API 502 Bad Gateway for top items endpoints when offset and limit exceed total

Hi, I have started getting 502 Bad Gateway errors when paginating using the "next" link from the API response body, when "limit" is not initially set to a factor of the total items.

 

ReubenF_1-1708481959678.png

 

I was successfully paginating with a "limit" of 49, which allowed me to get 49 more items beyond the stated total:

  • /me/top/{type}?limit=49 ("next" link /me/top/{type}?offset=49&limit=49)
  • /me/top/{type}?offset=49&limit=49 ("next" link /me/top/{type}?offset=98&limit=49)
  • /me/top/{type}?offset=98&limit=49 (no "next" link)

Now, I get a 502 Bad Gateway error for the last request to /me/top/{type}?offset=98&limit=49, despite the API providing the link.

 

When paginating in this way, this is only an issue for a "limit" which is not a factor of 100 (total number of items). You can see that for a "limit" of something that is a factor, like 25, there is no "next" link for the final response body:

  • /me/top/{type}?limit=25 ("next" link /me/top/{type}?offset=25&limit=25)
  • /me/top/{type}?offset=25&limit=25 ("next" link /me/top/{type}?offset=50&limit=25)
  • /me/top/{type}?offset=50&limit=25 ("next" link /me/top/{type}?offset=75&limit=25)
  • /me/top/{type}?offset=75&limit=25 (no "next" link)

For more context, see this related topic and this GItHub issue.

Reply

Accepted Solutions
Marked as solution

Hi ReubenF,

 

I just wanted to say thank you for reporting this. Indeed we did do a change in the backend where we replaced one upstream with another, and there was a bug with the pagination there. After you reported this we looked into it together with them and we believe we managed to sort it out.

 

Let us know if you are still experiencing issues with this. Otherwise, have a great day!

View solution in original post

2 Replies
Marked as solution

Hi ReubenF,

 

I just wanted to say thank you for reporting this. Indeed we did do a change in the backend where we replaced one upstream with another, and there was a bug with the pagination there. After you reported this we looked into it together with them and we believe we managed to sort it out.

 

Let us know if you are still experiencing issues with this. Otherwise, have a great day!

Hi, all looks good now - thanks! Was this change also responsible for allowing more than 100 top items to be retrieved in total? That's what I was referring to by "factor of 100" in the original post, where I was previously using that pagination quirk to get more than 100 top items back at a time (this is now not necessary as this limit seems to have been removed).

Suggested posts