Periodically when sending a query to the API, the Python requests library gets back a response code of 502. It’s basically a total failure when trying to send the query as there’s no data that actually comes back from the API, and therefore no request_id to reference.
Often times this will happen when the script is paginating through the long results set of a query. For example, I have one that uses the picks_per_day query and gets everything from the previous working day. In total there may be around 2000 records to download, and it will be going fine and then all of a sudden around the 8th page, for example, it will throw the 502 error. If I rerun the script, t will work fine. It’s like there’s a momentary hiccup in the API server and then it works again, but it’s enough to throw off the script.
So I guess my question is what is causing this 502 error, and is there any simple way around it?
Hi guys, sorry for the delay. @jeremyw this has been happening on the picks query only? could you share the query please? @mpspw could you please share the query? is it only with products?
The direct answer to your question is “yes”, I’ve only seen it happening on the picks_per_day query, but then again, it’s the only query where I’m actively monitoring the results. So, it could be happening elsewhere and I just haven’t seen it yet. Considering that mpspw has been seeing something similar on the products query, I’m guessing it’s not limited to picks_per_day.
Hi @seba It happens randomly, even when trying to acquire the access token or when refreshing token. I noticed it more on the product/products as these are the ones i have been messing around the most with lately.
Below are two example queries that returned said error.
Product:
query {
product(sku: “TESTPRODUCT”) {
complexity
request_id
data {
id
legacy_id
name
sku
barcode
country_of_manufacture
dimensions {
weight
height
width
length
}
tariff_code
kit
kit
no_air
final_sale
customs_value
customs_description
not_owned
dropship
needs_serial_number
thumbnail
large_thumbnail
created_at
updated_at
warehouse_products {
id
warehouse_id
on_hand
}
images {
src
position
}
tags
vendors {
vendor_id
vendor_sku
}
components {
id
}
}
}
}
@seba Just letting you know that the error keeps happening randomly but often for me, no matter if i’m fetching Shiphero data through code or if i’m just using the GraphQL client (when getting the schema also, as mentioned in my previous post).
This morning around 7am EST, Dec 3, I got another 502 error. It looks exactly the same as above. It came up after successfully pulling down 4400 picks. And I forgot to mention the other day it had pulled 5000 picks before giving the error.
Thanks guys, we are looking at the issue, it doesn’t seem to happen that often but we do have so possible improvements that we are going to try (have been busy with BF/CM). Will keep you posted.
we’re also getting this issue from seemingly at random while checking inventory. Since we’re paginating here this can break the entire call. Unfortunately I’m unable to set up retrys with our current system.
Could you please give us a status update on the issue?
Joining in on this - I seem to get the same 502 error frequently as well. It might be as much as 5% or more of calls I make.
I’ve come up with a workaround if you run into this while paginating. While looping through the pages, if it returns a 502 status code, just repeat the exact same request again. I made my call function very modular, so if response = 502 then call the same function passing the same parameters into it. If it is a success, then pass along next page info!
It is a bit of custom code, but I’ve found it good to use for almost any integration, as 502s can sporadically appear and shouldn’t disrupt you!
I get it when paginating orders and when paginating line items for those orders.
I’ve compensated by retrying after a reasonable amount of time and it hasn’t failed again after that interval yet, but it does add some complexity. Errors can happen with any service but they do happen pretty regularly when making a consecutive series of calls like @david says. Products for him, orders/line items for me, and picks per day for @jeremyw.
Sorry for the inconvenience, our devops team is working on this as we speak. We will probably have some news in a couple of weeks, so we will keep you posted.