OriginProtocol / dshop

Origin Dshop - launch your own decentralized store
https://www.originprotocol.com/dshop
MIT License
138 stars 87 forks source link

Printful auto-fulfillment failures due to invalid variant id #883

Closed franckc closed 3 years ago

franckc commented 3 years ago

I investigated an order auto-fulfillment issue reported by a merchant with a printful enabled shop (shop id 1531).

A few of their orders (for example: J25XTMME and HLBR9QG8) failed to auto-fullfill. The reason seems to be that in the data dir on disk, for some (but not all) products, the data.json file has variant ids that are not present in the printful-ids.json file.

For example, the order J25XTMME includes the product whale-line-tee. Here is an excerpt of whale-line-tee/data.json:

  "variants": [
    {
      "title": "Whale Line Tee - Black / S",
      "name": "Whale Line Tee - Black / S",
      "price": 2700,
      "image": "958f65f529bc81af5535074fc9f80ea8.jpg",
      "available": true,
      "id": 0,
      "externalId": 2396252583,
      "option1": "Black",
      "option2": "S",
      "option3": null,
      "options": [
        "Black",
        "S"
      ]
    },

Note how the variant has id 0.

But according to the printful-ids.json file, the variant id should actually be a 4 digits number. 2805 in this specific case:

  "whale-line-tee": {
    "2801": 2396252620,
    "2802": 2396252621,
    "2803": 2396252622,
    "2804": 2396252623,
    "2805": 2396252583,
    "2806": 2396252584,
    "2807": 2396252585,
    "2808": 2396252586,
    "2809": 2396252593,
    "2810": 2396252594,
    "2811": 2396252595,
    "2812": 2396252596,
    "2817": 2396252588,
    "2818": 2396252589,
    "2819": 2396252590,
    "2820": 2396252591,
    "2901": 2396252598,
    "2902": 2396252599,
    "2903": 2396252600,
    "2904": 2396252601,
    "2977": 2396252603,
    "2978": 2396252604,
    "2979": 2396252605,
    "2980": 2396252606,
    "3060": 2396252624,
    "3061": 2396252587,
    "3062": 2396252597,
    "3064": 2396252592,
    "3084": 2396252602,
    "3103": 2396252610
  },

As a result, the id lookup when generating the Prinful order fails. See this line.

I'm not sure what could cause this inconsistency between printful-ids.json and the product's data.json?

@nick or @shahthepro

As a side note, I'm also unclear as to why the code does that id lookup in the generatePrintfulOrder method rather than directly using the externalVariantId which is available in the order...

franckc commented 3 years ago

Checking the server logs for Failed to auto-fulfill order, the following shops are impacted:

   id | name            
------+---------------------------
 1531 | loldefi
 2723 | test tetsttdtaft afswgaeg
 1687 | SKALE
 2787 | Parabolic Fashion

The issue first started happening on Jan 6th and a total of 14 orders failed auto-fullfillment.

nick commented 3 years ago

Hrm this might be related to changes made to the variants product admin page. Will take a closer look...

franckc commented 3 years ago

Thanks.

FYI I checked the server logs and at least the good news is that for all of these orders, the merchant was notified by email of the fulfillment failure. e.g. this email was sent.

franckc commented 3 years ago

@shahthepro Any thoughts on possible root cause?

shahthepro commented 3 years ago

@franckc Will check it today. For the record, @phyninja feels it might be connected to #848