Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Barcode scan network error #895

Open
1 task done
jncosideout opened this issue Jan 17, 2025 · 8 comments
Open
1 task done

Barcode scan network error #895

jncosideout opened this issue Jan 17, 2025 · 8 comments

Comments

@jncosideout
Copy link

Description

Barcode scan search is not working. "No response from server" error message shown.

Reproduction Steps

  1. Turn on Wi-Fi
  2. Open Diary
  3. Scan a barcode. From the Foods/Meals/Recipes activity, tap the barcode button in the top right corner
  4. Barcode is recognized, but an error pop-up displays "No response from server"

Expected

App should search for the scanned barcode on OpenFoodFacts

Screenshots

Image

  • I searched for the bug in the Issues

Environment

App version: 3.9.2
Build: Installed from FDroid
Phone: Moto G7 Power
OS: "LineageOS with MicroG" 21 (LOS 21 is equivalent to stock Android 14)

@EmilJunker
Copy link
Contributor

"No response from server" means that the Open Food Facts website is down. This happens from time to time. There is nothing we can do about it.

@jncosideout
Copy link
Author

you're probably right. However, I should have mentioned I have checked status.openfoodfacts.org before I made this Issue and everything looked fine a few days ago. Waistline has not been able to reach OFF for several days now.

But looking at OFF server status now shows several incidents reported over the last two days...

@Baggypants
Copy link

Also hitting this. Other tools are working with OFF though e.g. https://git.justquitstudios.de/marco/calorimeter

@jncosideout
Copy link
Author

jncosideout commented Jan 29, 2025

I think I have ruled out OFF servers being the problem.

  1. I uninstalled Waistline
  2. Installed the last version of Waistline from FDroid 3.9.1
  3. Barcode scanning works again
  4. Upgraded back to 3.9.2, barcode scanning works

However I found a couple other bugs. Before uninstalling I exported my Waistline database json and diary_export.csv, but

  1. the import of the database did nothing in 3.9.1 and
  2. I couldn't find the diary_export.csv that it said was exported
  3. Tried importing the the database json via "Import foods from json" option and it kept failing
  4. After upgrading back to 3.9.2, database import still did nothing.
  5. "Import foods from json" also failing but finally worked when I picked an old backup I made months ago (and I tried several other old backups first)
  6. Barcode scanning stopped working after I imported successfully⁉

So maybe when I upgraded to 3.9.2 when it came out weeks ago, a database migration triggered something that broke barcode scanning??? 🤕

@EmilJunker
Copy link
Contributor

@jncosideout Wow, I'm very sorry you went through all those troubles. Unfortunately, you could have avoided them because there are perfectly fine explanations for what happened:

I think I have ruled out OFF servers being the problem.

  1. I uninstalled Waistline
  2. Installed the last version of Waistline from FDroid 3.9.1
  3. Barcode scanning works again

Probably just a coincidence. When Waistline sends search/barcode queries to OFF, it waits up to 15 seconds for a response. If the OFF server doesn't respond after 15 seconds, the request times out and Waistline displays an error message.

So, during a time when OFF servers are having issues, it may very well happen that you try to scan a barcode and it fails, and when you try again one minute later it succeeds. This has nothing to do with the version downgrade to 3.9.1.

  1. Upgraded back to 3.9.2, barcode scanning works

Exactly :)

However I found a couple other bugs. Before uninstalling I exported my Waistline database json and diary_export.csv, but

  1. the import of the database did nothing in 3.9.1 and

What do you mean by "did nothing"? Not even an error message? Did it at least open the file picker or did nothing happen at all?

  1. I couldn't find the diary_export.csv that it said was exported

First of all, the file diary_export.csv is NOT an export of the database. The database export file is called waistline_export.json.

The reason why you couldn't find the file is because most file manager apps on Android can't access the files under /Android/data/. You should be able to access them using the Files app from the Play Store or from APK mirror. Alternatively, you can use the new sharing feature that allows you to directly send the exported file to another app.

  1. Tried importing the the database json via "Import foods from json" option and it kept failing

The import foods from JSON feature is something different and it expects a slightly different file format (see the user guide). So of course you can't just import the waistline_export.json file like that.

  1. After upgrading back to 3.9.2, database import still did nothing.

I'm on version 3.9.2 and I just exported my database and successfully imported it afterwards. Everything works as expected.

Also, there a almost no differences between version 3.9.1 and 3.9.2. The only difference is in the food editor and unrelated to the database import or barcode scanning.

  1. "Import foods from json" also failing but finally worked when I picked an old backup I made months ago (and I tried several other old backups first)
  2. Barcode scanning stopped working after I imported successfully⁉

So maybe when I upgraded to 3.9.2 when it came out weeks ago, a database migration triggered something that broke barcode scanning??? 🤕

I think that's unlikely.

@Baggypants
Copy link

I can confirm. If I clear the app storage and cache the barcode scanner works again. If I clear the storage and cache again and then import my backup then the scanner reports "No response from Server"

I've attached my backup to help.

waistline_export.json

@EmilJunker
Copy link
Contributor

Okay, I see what is going on now. The reason why you get the "no response from server" error is because there is a problem with the way Waistline handles the configured search country.

When you scan a barcode, Waistline normally sends a request to the OFF server asking directly for the product with that barcode:

https://world.openfoodfacts.org/api/v0/product/3017620425035.json

However, if you have a non-default search country and/or search language configured, Waistline adds some parameters to the request. For example, like this:

https://world.openfoodfacts.org/api/v0/product/3017620425035.json&tagtype_0=countries&tag_contains_0=contains&tag_0=Germany&lang=de&lc=de

I think that's actually a bug in Waistline because these additional parameters only make sense when searching for a query string (like "nutella"), but not when directly searching for a barcode.

Anyway, the reason you see the error message is because your search country is set to "United Kingdom" which has a space in it, and apparently the OFF server can't handle that and returns a bad request response (hence, Waistline shows "no response from server"):

https://world.openfoodfacts.org/api/v0/product/3017620425035.json&tagtype_0=countries&tag_contains_0=contains&tag_0=United%20Kingdom&lang=en&lc=en

I'm pretty sure this was working in the past, so the most likely explaination is that OFF recently changed something that broke it.

@Baggypants @jncosideout For now, please go to Settings > Integration and set the Search Country to "All". This should fix the problem until we have a proper solution.

@jncosideout
Copy link
Author

Setting country to "All" resolved the error.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants