# Unexpected Error when query orders

**URL:** <https://community.shiphero.com/t/unexpected-error-when-query-orders/712>\
**Category:** GraphQL API\
**Created:** [August 31, 2020, 7:28am UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712 "2020-08-31T07:28:22Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [August 31, 2020, 7:28am UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/1 "2020-08-31T07:28:22Z")

</div>

Hi,

I’m trying to load sales orders history, but query fails with ‘Unexpected Error’ message. What is the reason of this error?

Query:  
{orders (updated\_from: “2018-08-31 07:24:31”) { data (first:100 ) {pageInfo {hasNextPage endCursor} edges {node { id }}}}}

Response:  
{“errors”:[{“message”:“Unexpected Error”,“operation”:“orders”,“field”:“data”,“request\_id”:“5f4ca5afd499c3f2887efae5”,“code”:22}],“data”:{“orders”:{“data”:null}}}

Thank you

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [September 1, 2020, 7:43pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/2 "2020-09-01T19:43:08Z")

</div>

@sb2020 I’ve seen this happen consistently with some of our older orders, but I never reached out to the dev team to determine the cause. My “fix” was to start my data pull from a more recent date (not an actual fix, I just decided that we could get by without that historical data).

For what it’s worth, I haven’t had this issue on any orders later than October of 2019.

---

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [September 2, 2020, 11:55am UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/3 "2020-09-02T11:55:36Z")

</div>

For me it fails for any orders query, not able even to load yesterday sales:  
query {orders (updated\_from: “2020-09-01 11:53:09”) { data (first:100 ) {pageInfo {hasNextPage endCursor} edges {node { id }}}}}

{“errors”:[{“message”:“Unexpected Error”,“operation”:“orders”,“field”:“data”,“request\_id”:“5f4f87a58ec9bfde4a83c940”,“code”:22}],“data”:{“orders”:{“data”:null}}}

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [September 3, 2020, 10:50pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/4 "2020-09-03T22:50:54Z")

</div>

Hi @sb2020  
I apologize for the delay in my response.  
I see the error you are mentioning and have already submitted a ticket to engineering to see why it might be happening. There seems to be an error with the Authorization part of the orders, but that should be resolved on our side.  
I will let you know as soon as I have an update from them.  
Thanks for the patience while we fix this.  
Tom

---

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [September 14, 2020, 7:01am UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/5 "2020-09-14T07:01:08Z")

</div>

Hi,  
Any update on this? We are not able to use integration because of this bug.

Thank you

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [September 14, 2020, 1:11pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/6 "2020-09-14T13:11:47Z")

</div>

Hi @sb2020  
I apologize for the delayed response, I just engaged our engineers to see if we could get a fix asap about this.  
Is it happening to multiple accounts or just this one?  
Thanks again!  
Tom

---

<div class="post-metadata">

**Author:** ![sb2020](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@sb2020](https://community.shiphero.com/u/sb2020)\
**Post date:** [September 15, 2020, 6:03am UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/7 "2020-09-15T06:03:05Z")

</div>

It is happening only to this account.

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [September 15, 2020, 12:18pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/8 "2020-09-15T12:18:20Z")

</div>

Thanks for clarifying that @sb2020  
An engineer has been assigned to work on this, so we should have news soon.  
I will let you know asap.  
Thanks again!  
Tom

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [October 30, 2020, 12:35pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/9 "2020-10-30T12:35:58Z")

</div>

Hey @tomasw!

We have an orders query that has been consistently failing with Code 22 for a couple days now. More info for your team to help get this solved hopefully.  
We reached out to support but were told the community is the best place for API support.  
Please let us know if this is still in progress and/or if your team has any news.  
Thank you!  
-Sid

Request IDs below:  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c072dbb3e7f6396466293’, ‘code’: 22}  
Wait 30 seconds…  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c074b019a8e02b02a71ed’, ‘code’: 22}  
Wait 30 seconds…  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c07698f64de9d3172970c’, ‘code’: 22}  
Wait 30 seconds…  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c07876f43cffa2d9a12fd’, ‘code’: 22}  
Wait 30 seconds…

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [October 30, 2020, 3:17pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/10 "2020-10-30T15:17:36Z")

</div>

@tomasw More info, I got our script to go ahead and include our query parameters in the output so I could see which order is giving us trouble.  
Order ID is T3JkZXI6MTQ3ODk0NTM2

Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c2e1e64110b941e555fde’, ‘code’: 22}  
id: “T3JkZXI6MTQ3ODk0NTM2”  
Wait 30 seconds…  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c2e3c166867d7467ed0ea’, ‘code’: 22}  
id: “T3JkZXI6MTQ3ODk0NTM2”  
Wait 30 seconds…  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c2e5adbe3c8dca9d7ce6d’, ‘code’: 22}  
id: “T3JkZXI6MTQ3ODk0NTM2”  
Wait 30 seconds…  
Querying…  
Quota used?..  
{‘message’: ‘Unexpected Error’, ‘operation’: ‘order’, ‘field’: ‘line\_items’, ‘request\_id’: ‘5f9c2e79a22fc2d869029755’, ‘code’: 22}  
id: “T3JkZXI6MTQ3ODk0NTM2”  
Wait 30 seconds…

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [October 30, 2020, 6:37pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/11 "2020-10-30T18:37:25Z")

</div>

@tomasw With that diagnosed, we were able to add a temp fix to our script to get around this problematic order, and then everything else went through properly.

We can’t simply skip data whenever we get a code 22 response since they happen randomly/sporadically. Maybe we could add some logic in to go ahead and skip the data if we consistently get a code 22 for the same request after X times. I’d really rather avoid that, and since the request is valid the ideal behavior of course would be that it eventually gets a valid response.

FYI, this is pertinent to our python scripts only, but here’s the jist of how we put a fix in place once we knew the problematic order id:

> ```
> if query_params == "id: \"T3JkZXI6MTQ3ODk0NTM2\"":
> # Temp fix for sh**ty order
> has_next_page = False
> 
> ```

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [October 31, 2020, 3:13pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/12 "2020-10-31T15:13:39Z")

</div>

Hi @sb2020 & @originsid!

A fix for this should have been implemented on 16/10/2020 I apologize for the delayed update about it.

@originsid  
I believe that might not be related to this fix, and that order has an invalid value for one of the line items price, causing it to break the response, this is:

**Order ID:** T3JkZXI6MTQ3ODk0NTM2 is seen this way in the UI:

 ![Screen Shot 2020-10-30 at 23.45.10](https://us1.discourse-cdn.com/flex020/uploads/shiphero/original/1X/828e06865d88d0b24c321384e4298562bddf5bca.png)

If you want I could try to set that value on the backend, but I would need you to confirm what value should that be.

Thanks in advance!

Tom

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [November 2, 2020, 3:38pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/13 "2020-11-02T15:38:03Z")

</div>

Thank you @tomasw!

For that specific line item, it was manually added to the order, and it looks like the intent was to zero out the pricing on it. Most likely we deleted the price and saved it, rather than setting it to 0.00

Does that make sense as a cause of this? Should we make sure it’s standard procedure to never set a blank value for price on a line item?

Since we’d rather not do any strange re-shipping for this one to correct it, would you mind setting that value to 0.00 on the backend as you described?

Thank you again!

-Sid

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [November 3, 2020, 2:13pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/14 "2020-11-03T14:13:13Z")

</div>

Hi @originsid  
The issue should be resolved by now! I set it to be 0.00

> [@originsid](#):
>
> Does that make sense as a cause of this? Should we make sure it’s standard procedure to never set a blank value for price on a line item?

It does make sense, for example, if when creating an order you try to set a letter for the value “ABC” you will get an error because it is not a number. So I think it is possible that might have happened.

Let me know if you continue to face this kind of issue or if there is anything else I could help with.  
Thanks again!  
Tom

---

<div class="post-metadata">

**Author:** ![originsid](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@originsid](https://community.shiphero.com/u/originsid)\
**Post date:** [November 3, 2020, 2:53pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/15 "2020-11-03T14:53:47Z")

</div>

Thank you @tomasw!  
FYI in the order history for this one, I can see the log shows “removed price”.  
If removing the price on a line item is normal behavior, I think it would be preferable for the API to handle line items with the price removed, but if it’s not normal behavior I definitely understand that and I think it would be preferable to force the price to be 0.00

If it makes more sense to allow the price to be removed but not handle those line items well via the API then there may be a use case I’m missing, happy to learn more about it.

Currently we wouldn’t have a way to detect line items with no price since we can’t pull that data via the API.

Thank you!

-Sid

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [November 4, 2020, 12:45pm UTC](https://community.shiphero.com/t/unexpected-error-when-query-orders/712/16 "2020-11-04T12:45:46Z")

</div>

Hi @originsid!  
Makes sense to report that change.  
I think forcing it to `0.00` might be the best call, empty prices might cause some issues and not only here on the Public API (generating invoices for example)  
I will try to reproduce on my test account and submit a ticket for that to be changed.  
Thanks again for catching this! And let me know if there is anything else I could help with  
Tom
