woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ #4834

Open sentry-io[bot] opened 3 years ago

sentry-io[bot] commented 3 years ago

Sentry Issue: WOOCOMMERCE-ANDROID-26S

java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
    at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
    at com.google.gson.Gson.fromJson(Gson.java:932)
    at com.google.gson.Gson.fromJson(Gson.java:897)
    at com.google.gson.Gson.fromJson(Gson.java:846)
    at org.wordpress.android.fluxc.model.WCOrderModel.getLineItemList(WCOrderModel.kt:164)
    at org.wordpress.android.fluxc.model.WCOrderModel.getOrderSubtotal(WCOrderModel.kt:171)
    at com.woocommerce.android.model.OrderKt.toAppModel(Order.kt:272)
    at com.woocommerce.android.ui.orders.details.OrderDetailRepository.getOrder(OrderDetailRepository.kt:197)
    at com.woocommerce.android.ui.orders.details.OrderDetailViewModel.start(OrderDetailViewModel.kt:153)
    at com.woocommerce.android.ui.orders.details.OrderDetailFragment.setupObservers(OrderDetailFragment.kt:220)
    at com.woocommerce.android.ui.orders.details.OrderDetailFragment.onViewCreated(OrderDetailFragment.kt:114)
nbradbury commented 3 years ago

First seen in release 7.3. Currently 233 events and 10 users.

Screen Shot 2021-09-22 at 11 49 58 AM
reginabally commented 3 years ago

We have a user report in 4372959-zd-woothemes on 7.7-rc-3. Sentry report for this user.

Click to view list of active plugins
تأكيدات التحويلات البنكية: by AhmadWael - 1.1.0
WC Checkout Fields Customizer: by AhmadWael - 1.0.0
الربط مع سمسا: by cedcommerce - 2.0.0
الحقول المخصصة المتقدمة للمحترفين: by إليوت كوندون - 5.9.3 (update to version 5.10.2 available)
Aramex Shipping WooCommerce: by aramex.com - 1.1.6 (update to version 1.1.10 available)
CLEX Shipping WooCommerce: by CLEX team - 1.0
Contact Form 7: by Takayuki Miyoshi - 5.4.2 (update to version 5.5.1 available)
قنوات ووكومرس دروب شيبنج: by قنوات - 2.2.0
Facebook for WooCommerce: by Facebook - 2.6.1 (update to version 2.6.5 available)
صورة مميزة حسب الرابط: by Knawat - 1.1.7
WooCommerce Google Ads Dynamic Remarketing: by Wolf+Bär Agency - 1.7.14
Media Cloud: by interfacelab - 4.2.6 (update to version 4.2.37 available)
Woocommerce UI Mobile Bar: by Ahmad Wael - 0.1.3
InnoShop Software Products: by أحمد وائل - 1.0
Jetpack: by Automattic - 10.0 (update to version 10.2 available)
qTranslate-XT: by qTranslate Community - 3.10.1
Smart Wishlist: by Ahmad Wael - 1.1
Snap Pixel: by Hassan Ali - 1.5.4
WooCommerce Tap Payment Gateway: by Waqas Zeeshan - 2.0
التحكم فى ظهور المنتجات للوكومرس: by أحمد وائل - 1.0.0
WooCommerce Smart COD: by woosmartcod.com - 1.6.1
الشحن مع ويمو لمتاجر ووكومرس: by أحمد وائل - 1.0.5
WhatsApp Button: by innoshop - 1.0
Shopz GraphQL API for WooCommerce: by Shopz.io - 2.1.5
Variation Swatches for WooCommerce: by Emran Ahmed - 1.1.17 (update to version 1.1.19 available)
WooCommerce Aymakan Shipping: by Aymakan - 1.3.0
Print Invoice & Delivery Notes for WooCommerce: by Tyche Softwares - 4.6.4
Booster for WooCommerce: by Pluggabl LLC - 5.4.4 (update to version 5.4.7 available)
WooCommerce: by Automattic - 5.5.2 (update to version 5.8.0 available)
Yoast SEO: by Team Yoast - 16.9 (update to version 17.3 available)
WP All Import Pro: by Soflyy - 4.6.9
لوحة تحكم وردبريس المبسطة: by أحمد وائل - 0.8.38
WP All Import - WooCommerce Add-On Pro: by Soflyy - 3.2.7
designsimply commented 3 years ago

I checked the site_url list in the Sentry tags for this crash report and noticed almost all the reporting sites are written in Arabic. It may also be worth noting that the latest user reporting the problem mentioned it happens consistently for them when they try to open order details.

ThomazFB commented 3 years ago

I've managed to reproduce the issue and it's caused by a malformed line items JSON data, this is most likely a plugin messing with the site API. It would be great if any of our merchants manages to pinpoint which Plugin is doing so.

Nevertheless, I don’t think our app should be able to handle modified data like this, we can avoid the crash though. But if we manage to identify the plugin doing this, it would be the case to ask the merchant to contact the plugin support.

here's an example of how the data is reaching the app:

{
   "0":{
      "id":527,
      "name":"",
      "product_id":661,
      "variation_id":0,
      "quantity":1,
      "tax_class":"",
      "subtotal":"25",
      "subtotal_tax":"0",
      "total":"25",
      "total_tax":"0",
      "taxes":[

      ]
   },
   "1":{
      "id":528,
      "name":"",
      "product_id":717,
      "variation_id":0,
      "quantity":1,
      "tax_class":"",
      "subtotal":"35",
      "subtotal_tax":"0",
      "total":"35",
      "total_tax":"0",
      "taxes":[

      ]
   },
   "serial_keys":""
}

And here's how the app expects to handle it:

[
    {
       "id":65,
       "name":"Belt",
       "product_id":15,
       "variation_id":0,
       "quantity":2,
       "tax_class":"",
       "subtotal":"110.00",
       "subtotal_tax":"0.00",
       "total":"110.00",
       "total_tax":"0.00",
       "taxes":[

       ]
    },
    {
       "id":64,
       "name":"Pizza",
       "product_id":533,
       "variation_id":0,
       "quantity":1,
       "tax_class":"",
       "subtotal":"325.56",
       "subtotal_tax":"0.00",
       "total":"325.56",
       "total_tax":"0.00",
       "taxes":[

       ]
    }
 ]
sentry-io[bot] commented 2 years ago

Sentry issue: WOOCOMMERCE-ANDROID-3XC