woocommerce-ios
woocommerce-ios copied to clipboard
Error loading products (Swift.DecodingError) on variations
Describe the bug Reported in 4541101-zd-woothemes.
Similar to this issue, the app wasn't able to load the stats and products because of the following error:
2021/11/24 16:31:13:622 ⛔️ Error loading dashboard: typeMismatch(Swift.Int64, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "variations", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "Expected to decode Int64 but found a dictionary instead.", underlyingError: nil))
The user found out the error was caused by the wePOS - Point of Sales (POS) for woocommerce
extension through the plugin conflict test.
Mobile Environment I was able to reproduce this in SSP with:
- Device: iPhone SE
- iOS version: 14.8.1
- WooCommerce iOS version: 7.9
List of plugins (Complete SSR included in the ticket)
Branda: by WPMU DEV – 3.4.5.1 Code Snippets: by Code Snippets Pro – 2.14.2 Cost of Goods for WooCommerce: by WPFactory – 2.4.9 Facebook for WooCommerce: by Facebook – 2.6.7 Facebook Chat Plugin - Live Chat Plugin for WordPress: by Facebook – 2.2 Flexible Shipping: by WP Desk – 4.10.1 GenerateBlocks: by Tom Usborne – 1.4.0 Site Kit by Google: by Google – 1.46.0 GP Premium: by Tom Usborne – 2.1.1 Jetpack: by Automattic – 10.3 Smart Slider 3 Pro: by Nextend – 3.5.1.2 Post SMTP: by Yehuda Hassine – 2.0.23 Rank Math SEO: by Rank Math – 1.0.76.1 SiteGround Optimizer: by SiteGround – 6.0.5 Stock Exporter for WooCommerce: by Webdados – 1.0.0 WC Hide Shipping Methods: by Rynaldo Stoltz – 1.5 WooCommerce No Shipping Message: by dangoodman – 2.0.12 Payments via PayMongo for WooCommerce: by CynderTech – 1.6.2 wePOS - Point Of Sale (POS) for WooCommerce: by weDevs – 1.1.11 Checkout Field Editor for WooCommerce: by ThemeHigh – 1.5.0 WooCommerce: by Automattic – 5.9.0 Hustle: by WPMU DEV – 7.4.7 Smush: by WPMU DEV – 3.9.2 wpDiscuz: by gVectors Team – 7.3.8 Custom Product Tabs for WooCommerce: by YIKES Inc. – 1.7.7
Inactive Plugins (1)
GoWP WooCommerce Variations Apply All: by GoWP – 1.0.3```
Another report here: 4655074-zen
User has tried the plugin conflict test. They found out that disabling Code Snippets does help with loading the Product tab, but it does not help with the app loading very slowly. However, none of these issues occur on their Android app.
https://user-images.githubusercontent.com/35628116/148904516-1fe0db94-881b-4215-b4fc-d44c8518f23e.mp4
I was able to reproduce this in SSP with:
Device: iPhone SE iOS version: 15.2 WooCommerce iOS version: 8.1.1
4655074-zen mentioned they also see this error, not sure if it's related:
2022-01-06T10:22:40+00:00 CRITICAL Uncaught Error: Class 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\DeprecatedOptions' not found in /home/echipame/public_html/wp-content/plugins/woocommerce/packages/woocommerce-admin/src/Features/OnboardingTasks/Init.php:42
Stack trace:
#0 /home/echipame/public_html/wp-content/plugins/woocommerce/packages/woocommerce-admin/src/Features/OnboardingTasks/Init.php(33): Automattic\WooCommerce\Admin\Features\OnboardingTasks\Init->__construct()
#1 /home/echipame/public_html/wp-content/plugins/woocommerce/packages/woocommerce-admin/src/Features/Onboarding.php(62): Automattic\WooCommerce\Admin\Features\OnboardingTasks\Init::get_instance()
#2 /home/echipame/public_html/wp-content/plugins/woocommerce/packages/woocommerce-admin/src/Features/Features.php(136): Automattic\WooCommerce\Admin\Features\Onboarding->__construct()
#3 /home/echipame/public_html/wp-includes/class-wp-hook.php(303): Automattic\WooCommerce\Admin\Features\Features::load_features('')
#4 /home/echipame/public_html/wp-includes/class-wp-hook.php in /home/echipame/public_html/wp-content/plugins/woocommerce/packages/woocommerce-admin/src/Features/OnboardingTasks/Init.php on line 42
I just want to mention that the issue happened in 4655074-zd-woothemes is not related to the "variations" data field, it's on "weight" according to the app log:
2022/01/03 09:42:20:470 ⛔️ Error synchronizing products: typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "weight", intValue: nil)], debugDescription: "Expected to decode String but found a number instead.", underlyingError: nil))
Also, if disabling Code Snippet helps, then this ticket is no longer relevant here. The issue now is about the iOS app loading slow, which is irrelevant to the originally reported issue.
Second report of this for a user who has the wePOS - Point Of Sale (POS) for WooCommerce
plugin in 5415519-zd-woothemes.
Issue in #6174678-zen seems related:
2023/04/04 20:47:48:413 ⛔️ Error synchronizing products: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
They don't have any of the plugins mentioned so far, so asked them to conflict test and report back with their results.
#6240912-zen:
2023/04/27 15:12:00:330 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
I asked them to conflict test and report back with what they find.
6254405-zen:
2023/05/02 16:31:40:535 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Asked them to do the conflict test.
6249416-zen:
2023/05/01 04:51:43:684 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
They have Code Snippet plugin so asked them to try disabling that first.
User in #6247326-zen was reporting a similar issue. Here's a snippet from the logs:
2023/04/29 20:38:53:290 ⛔️ Error synchronizing products: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Interestingly, they said that, after loading their products on Android, it started working on iOS too:
I can reload it now, but to solve the problem I installed Woo app on a different device that uses Android, because my main phone is an IPhone. After refreshing the products on the Android phone, it worked on my IPhone.
6268968-zen:
2023/05/07 16:00:47:225 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Asked to do plugin conflict test.
#6266421-zen:
2023/05/06 04:01:51:215 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
They have the Code Snippets plugin, so asked them to test temporarily disabling it.
#6269295-zen:
2023/05/07 19:33:44:761 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Asked for SSR so we can check plugins.
#6243425-zen trouble loading orders, with same error as other recent reports
2023/04/27 18:35:07:088 🔵 Tracked orders_list_load_error, properties: [AnyHashable("blog_id"): 213782013, AnyHashable("error_code"): "4864", AnyHashable("error_domain"): "NSCocoaErrorDomain", AnyHashable("error_description"): "Swift.DecodingError.typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: \"Expected to decode Array<Any> but found a dictionary instead.\", underlyingError: nil))", AnyHashable("is_wpcom_store"): false]
They have sent an SSR. I'm asking them to do a plugin conflict test
#6265159-zen trouble loading orders, with same error as other recent reports
2023/05/08 09:06:54:928 <> Mapping Error: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
I'm asking them to plugin conflict test
#6267247-zen is having identical trouble
2023/05/06 12:50:05:029 <> Mapping Error: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Asking them to conflict test
#6270484-zen identical troubles loading orders.
2023/05/08 09:45:48:061 <> Mapping Error: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Asking them to conflict test
#6270676-zen Orders not loading
2023/05/06 12:56:41:959 ⛔️ Error synchronizing orders: typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
I'm following up on the increase in reports of a decoding error when loading orders. Here's a quick recap of what I'm seeing:
- Reports are from users with WCiOS 13.1 or 13.2.
- There aren't any changes from 13.1 or 13.2 in how orders are being decoded (the
Order
model or related models). - The errors are vague but if we can't pinpoint the cause for all of the reports right now, the errors should be clearer (and thus easier to investigate) with the change from https://github.com/woocommerce/woocommerce-ios/pull/9510 in the 13.3 release.
- The first report (of this recent increase) is from April 27, which coincides with the latest WooCommerce Core release (7.6.1, released on April 26).
- There are stores using WooCommerce 7.6.1 that can load orders in the app, so if it's related to core it isn't a universal issue.
However, while investigating I did manage to trigger an order decoding error on one of my test stores:
⛔️ Error synchronizing orders: dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _JSONKey(stringValue: "Index 6", intValue: 6), CodingKeys(stringValue: "payment_url", intValue: nil)], debugDescription: "Invalid URL string.", underlyingError: nil))
It looks like these are caused by invalid URL strings for the payment URL on subscription renewal orders (related to the WooCommerce Subscriptions extension). I see that at least some of the stores reporting an issue have the WooCommerce Subscriptions extension, as well, so this could be the cause for at least some of these new reports. I'm opening a separate issue https://github.com/woocommerce/woocommerce-ios/issues/9683 to follow up on that specific error.
Please continue to check what plugins are activated on the stores reporting this issue, to see if there are other potential causes or common plugins that might be causing an error loading orders.
Looping back here to note that the issue loading orders with the WooCommerce Subscriptions extension (#9683) will be resolved with the WooCommerce Subscriptions 5.1.2 release.
If anyone reports further decoding errors, please continue to report them. In that case, it would help to open a separate issue for each error, since they have to be addressed/resolved individually. I'll leave this issue open since the original report is for this decoding error caused by the wePOS - Point of Sales (POS) for woocommerce
extension:
2021/11/24 16:31:13:622 ⛔️ Error loading dashboard: typeMismatch(Swift.Int64, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "variations", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "Expected to decode Int64 but found a dictionary instead.", underlyingError: nil))
I'm closing this issue because the original decoding error should be resolved by https://github.com/woocommerce/woocommerce-ios/pull/9857 (shipped in 14.0). 🎉