Purchase Order - Unknown 22 Error

Hello -

My job has been failing for the past couple of days due to an unknown error code that is popping up. This code has never popped up before for the same query that was running without complication for months.
Here is the error I am receiving:

 "errors":[
  {
     "message":"Unexpected Error",
     "operation":"purchase_order",
     "field":"line_items",
     "request_id":"5f43be7339bccd3d47ed53d5",
     "code":22}],
 "data":{
   "user_quota":{
    "is_expired":false,
     "time_remaining":null,
     "credits_remaining":990},
   "purchase_order":{
     "complexity":11,
     "data":{
       "line_items":null}}}

This is from query:

query {
  user_quota {
    is_expired
    time_remaining
    credits_remaining
  }
  purchase_order(id: "UHVyY2hhc2VPcmRlcjozNTY3OTI=") {
    complexity data {
      line_items(first: 10, after: "YXJyYXljb25uZWN0aW9uOjQ=") {
        pageInfo {
          hasNextPage
          hasPreviousPage
          startCursor
          endCursor
        }
        edges{
          node {
            id
            po_id
            account_id
            vendor_id
            sku
            vendor_sku
            product_id
            variant_id
            product_name
            quantity
            quantity_received
            quantity_rejected
            sell_ahead
            price
            fulfillment_status
            updated_at
            created_at
          }
          cursor
        }
      }
    }
  }
}

Would someone be able to provide me assistance? I thought this may work Shipments Query Giving Unexpected Error - Code 22 but it seems as though there is more filters available in this query and would require a large amount of parsing to pull back the info. Line item only allows for:

sort
after
before
first
last

Also, timing wouldn’t make sense to filter by since all of the items are most likely created at the same time. Please let me know as soon as possible as this impacts my ability to pull in orders efficiently.

Thanks,
Nick

The issue of the linked topic was that the data set for shipments was apparently so large that the system couldn’t return a response fast enough (or it was running into an error). With filtering the query to use a time-based filter on the shipment itself, I limited the pool of data that needs to be looked at / cached to return a result.

It looks like your query is a jumbled. You may want to edit that query to fix it, and use the “Preformatted text” button ( </> ) to make it a bit more readable.

Thanks @brett !

Didn’t notice that option when typing this out :sweat_smile:

Yes from the ticket I referenced (from your issue) that seems to be the case, but I don’t see that option available when querying the line items from the purchase order query. The purchase order query is already filtering by ID, and there are some 214 items attached to it. This query has been working for months with no issues and I only did 10 at a time given the amount of credits available and the way you are charged for them (i.e. if i do first 100 and it only has 5 results…i’m down 100 instead of 5 to my understanding).

I could potentially do this by doing before and after cursor, but I don’t have the cursors at the moment of running the job. So need to find a way to be able to bring in all this information so that my client can see their purchase order history. A great option for filtering would be an updated_at field but my last ticket I raised this and it was turned down - which i’m not sure why.

Thanks,
rubix3

Hello -

I’m looking to get an update on the above. This is business critical data that our clients rely upon to make decisions for purchasing more product. Please take a look when you can.

Thanks,
Nick

HI @rubix3!
It might be related to unexisting SKUs on the PO.

There seem to be some products, for example SKU: HGLV105PUR_XL that don’t exist on the warehouse.

Is it a common practice to have purchase orders with unexisting SKUs?
I will log a request to improve the error message or support this cases in the meantime, but want to get to the root cause

In the meantime, creating those products in the warehouse should solve the issue
Thanks in advance!
Tom

Hello @tomasw -

I appreciate the feedback and support on this effort. I can circle back with our client to see how often this may have occurred. Please let me know once you are able to get further down to the root cause in this scenario. An improved error code would definitely help with the ambiguity :smile:. I will run some tests on my end as well to see if there are other POs that this causes an error on as well.

Thanks again,
Nick

Sounds good @rubix3!
I just confirmed that adding the product will fix the issue with a test purchase order I created on my account.
I also submitted a ticket for this to be handled better showing an appropriate error message.

The reason the error is displaying is because the query contains fields for the line items such as sku price… but the SKU doesn’t exist on the warehouse, so when attempting to get that information is returning an error because it is not finding it.

Thanks again!
Tom

Hey @tomasw -

Appreciate the follow up on your end! We spoke with our client and it didn’t seem as though this was a new occurrence for them to delete out old skus. Was a change made in the past week that could’ve caused this new error?

In any case, we can also work with them to see what SKUs for them to recreate. Is it possible to see these deprecated SKUs when making a pull to the product node?

Thanks,
Nick

Hi @rubix3
Absolutely! I will check with the POC for this account and let them know what SKUs should be recreated so they can reach the customer, and also ask them if this can be avoided in the future (if possible)
I did open a ticket to handle better these cases, and in case we are not able to return the line items, to show a proper error message for this
Thanks again! And I will update once I have more info about it
Tom

Hello @tomasw -

Have you been able to reach the POC for this account? Seems like they did not resolve the issue with our client. We are hoping to find the SKUs needed to re-create so we can turn our connector back on.

Thanks,
@rubix3

Hi @rubix3!
I apologize for the delayed response abut this.
We did, but I just also raised the priority for the request for this to be fixed on the Public API side (to have a better error handling and be able to return it null instead of the error, or a friendlier error.
Thanks again for the patience and I will provide an update as soon as possible.
Tom

Hi @tomasw , I believe I have the exact same issue: one specific PurchaseOrder with line items is systematically failing with code 22. Was this issue resolved and my error is different? or is this still failing when there’s an unknown SKU in one line item?
Note that I’m happy to have a response that skips unknown SKUs if thats the way to fix it, but failing to return a big PO because of one line item is difficult to handle and explain to my client.
Also, do you know if the REST API has the same issue?
Thanks! Thierry

Hi @thierrybm!
Welcome to the community and thanks for that description!
Is there any chance you could share the Request ID? That is, to make sure it is this exact same error

As for the Rest API, it has been removed, and currently only the GraphQL only available
Thanks in advance!
Tom

Thanks @tomasw , I just re-ran it, here is the request ID: “601030d916abddbc281ad46d”

Thanks for that @thierrybm!
Looks like the same one, I will raise the priority of the issue.
In the meantime, creating those unexisting products in the warehouse should solve the error.
Thanks for the patience while we work on this!
Tom