woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
294 stars 108 forks source link

EXC_BREAKPOINT: Error saving OrderItemAttribute with nil values to Storage #8454

Closed sentry-io[bot] closed 1 month ago

sentry-io[bot] commented 1 year ago

Sentry Issue: WOOCOMMERCE-IOS-1CX1

EXC_BREAKPOINT: /usr/local/var/buildkite-agent/builds/MV-MKE-X64-018/automattic/woocommerce-ios/Storage/Storage/Extensions/NSManagedObjectContext+Storage.swift:141: Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134030 "Er heeft zich een fout voorgedaan tijdens het bewaren." UserInfo={NSAffectedObjectsErrorKey=(
    "<OrderItemAttribute: 0x2819eeb20> (entity: OrderItemAttribute; id: 0x283b017a0 <x-coredata:///OrderItemAttribute/tAF49C32E-385B-4BE6-92FA-01A391145989575>; data: {\n    metaID = 0;\n    name = nil;\n    orderFeeLine = nil;\n    orderItem = nil;\n    orderTaxLine = nil;\n    value = nil;\n})"
)}, ["NSAffectedObjectsErrorKey": <__NSSingleObjectArrayI 0x283877690>(
<OrderItemAttribute: 0x2819eeb20> (entity: OrderItemAttribute; id: 0x283b017a0 <x-coredata:///OrderItemAttribute/tAF49C32E-385B-4BE6-92FA-01A391145989575>; data: {
    metaID = 0;
    name = nil;
    orderFeeLine = nil;
    orderItem = nil;
    orderTaxLine = nil;
    value = nil;
})
)
]

  File "main.swift", line 7, in main
...
(13 additional frame(s) were not displayed)

See also this Slack discussion (internal ref): p1663056414201389-slack-C6H8C3G23

peril-woocommerce[bot] commented 1 year ago
Fails
:no_entry_sign: Please add a type label to this issue. e.g. 'type: enhancement'
:no_entry_sign: Please add a feature label to this issue. e.g. 'feature: stats'

Generated by :no_entry_sign: dangerJS

rachelmcr commented 1 year ago

As discussed in Slack, many of the errors causing this crash (all of the recent ones I spot-checked) were caused by an invalid OrderItemAttribute. In Storage, OrderItemAttribute has non-optional name and value strings, but with no default string value.

It's unclear how an attribute with all of these properties nil can get to the point where it's being saved (which causes this error). One solution could be to update the OrderItemAttribute storage entity to use default empty strings for these non-optional attributes, to avoid the crash. (Although that doesn't resolve the underlying issue where an attribute can have these nil properties.)

jaclync commented 1 year ago

linking the previous Slack discussion: p1663056414201389-slack-C6H8C3G23 - it'd be great to find the root cause of OrderItemAttribute being saved with nil properties, but we haven't found it 😞

rachelmcr commented 1 year ago

This crash has affected 311 users over the past 14 days and is currently our biggest crash (most crash events and most users affected). Internal ref: peaMlT-3M-p2

pmusolino commented 1 month ago

Closing this since it was archived on Sentry.