New issue

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

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

Already on GitHub? Sign in to your account

Invalid barcodes return random products #1649

Open
teolemon opened this Issue Feb 4, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@hangy

This comment has been minimized.

Copy link
Member

hangy commented Feb 4, 2019

It's not actually random. The JSON is a bit confusing, because the order of properties seems to be randomized every time, but when you use the XML version, you see that it's always the same "product" - even for different alphanumeric product codes:

But not for

Unrelated, but weird, too:

I think the main issue with "random" working is, that a product without a code exists in the products directory. There's probably a .sto file without an actual name of the file there. The reason why https://world.openfoodfacts.org/api/v1/product/2asdasdkjk.xml is found in normalize_code:

$code =~ s/\D//g; # Keep only digits, remove spaces, dashes and everything else

We may want the API to be more strict about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment