openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
853 stars 282 forks source link

_Exception: Exception: no product for barcode 9135720000775320488 #687

Closed sentry-io[bot] closed 2 years ago

sentry-io[bot] commented 2 years ago

Sentry Issue: SMOOTHIE-ANDROID-1R

_Exception: Exception: no product for barcode 9135720000775320488
  File "product_list.dart", line 351, in ProductList.getList
  File "product_list_page.dart", line 39, in _ProductListPageState.build
...
(18 additional frame(s) were not displayed)
monsieurtanuki commented 2 years ago

@teolemon Could not reproduce it. Is that systematic? And where the hell does 9135720000775320488 come from: is that a product you created?

Perhaps a "bad luck" bug, as in product list there are 3 fields...

... and maybe at the moment you go to the page, while loading the product list and before it's over, the display is refreshed for some reason, asking for not fully completed data regarding those 3 fields (loaded one by one).

monsieurtanuki commented 2 years ago

Automatically closed... I've just reopened it, as I'm not sure my fix (which was a safer code anyway) was good enough. It's merged now (#689): please @teolemon @M123-dev try to reproduce the crash with that new code.

teolemon commented 2 years ago

Still crashing here. Going to look into additional traces.

monsieurtanuki commented 2 years ago

@teolemon I still find that barcode 9135720000775320488 fishy. Do you know where it comes from?

teolemon commented 2 years ago

No idea, It's something that I scanned, somehow (like those special logistic barcodes) Exactly the same trace as before.

monsieurtanuki commented 2 years ago

@teolemon I think I understand what's going on. One day you scanned your blablabla barcode. That obviously did not match a product. But still, you did scan that barcode. In the database we store the fact that you scanned that barcode at that moment. But we cannot store a corresponding product. And in the product list, we want a list of actual products, not a list of potentially failed attempts to find products that match barcodes. I'm about to PR.

monsieurtanuki commented 2 years ago

Automatically closed again... I reopen it: @teolemon would you please test again, with #696 being merged? There might be useful logs printed - and no more crash.

teolemon commented 2 years ago

fixed @monsieurtanuki

monsieurtanuki commented 2 years ago

That's good news @teolemon!

There are maybe some fine-tunings to code later as we are in a grey zone with the carousel

  1. initially loaded with scanned barcodes with products (that's the #696 fix)
  2. but with additional scanned barcodes potentially with no matching products

While we're in a session, the carousel will (probably) display the barcodes with no products (as "not found"), but when we restart the app, the unknown barcodes will disappear because of the initial carousel reload excluding them as without product.

Beyond the fix that prevents the crash, there's now a debug print for those "disappearing" unknown barcodes.

It looks like we're ready to close the issue.

teolemon commented 2 years ago

Ok, I scanned a QR code, and it's back

_Exception

product_list.dart in ProductList.getList

Exception: no product for barcode https://qrco.de/bbrpYf
teolemon commented 2 years ago

image

Fixed for me. Thanks @monsieurtanuki , closing again :-)

monsieurtanuki commented 2 years ago

@teolemon The good news is that it's fixed. The bad news is that we still don't know why it crashed - probably because there was no product related to the barcode, but why did we land in those situations?

The fix was to say: if there's no actual product, we ignore the barcode.

To be tested: stupid barcodes (e.g. 11111111111111111111111) and unknown products (e.g. shampoo). There's a high probability that on those cases, the product is not really put in the list (e.g. history). Is that really a problem? In some cases I guess.