Skip to content
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
Tracked by #5523
teolemon opened this issue Feb 4, 2019 · 1 comment
Open
Tracked by #5523

Invalid barcodes return random products #1649

teolemon opened this issue Feb 4, 2019 · 1 comment
Labels
API READ All READ APIs include Product, Search… API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…)

Comments

@teolemon
Copy link
Member

teolemon commented Feb 4, 2019

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

@teolemon teolemon added 🐛 bug This is a bug, not a feature request. API READ All READ APIs include Product, Search… labels Feb 4, 2019
@hangy
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.

@teolemon teolemon added the API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) label Aug 21, 2021
@teolemon teolemon moved this to To discuss and validate in 🍊 Open Food Facts Server issues Apr 23, 2024
@teolemon teolemon removed the 🐛 bug This is a bug, not a feature request. label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API READ All READ APIs include Product, Search… API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…)
Projects
Status: To discuss and validate
Development

No branches or pull requests

2 participants