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

301 response makes it difficult to implement a feature #6993

Closed
teolemon opened this issue Jul 1, 2022 · 2 comments · Fixed by #7019
Closed

301 response makes it difficult to implement a feature #6993

teolemon opened this issue Jul 1, 2022 · 2 comments · Fixed by #7019
Labels
🤳🥫 blocking mobile apps This issues are blocking a feature on the Open Food Facts mobile apps Tags.pm Tags 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies

Comments

@teolemon
Copy link
Member

teolemon commented Jul 1, 2022

@teolemon @stephanegigandet Actually there's a little bug I've just discovered, on the server side.

With the latest version of off-dart, we also put the language in the query. Which is a good idea, isn't it?

It works well for the first 3 queries (contributor, informer, photographer).
But for the last one ("to be completed") the server translates the URL, and that fails.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="/informateur/monsieurtanuki/etat/a-completer.json">here</a>.</p>
<hr>
<address>Apache/2.4.25 (Debian) Server at world.openfoodfacts.org Port 80</address>
</body></html>

What shall we do? Should we handle that in off-dart? Is that a bad redirection code on the server side?

Originally posted by @monsieurtanuki in openfoodfacts/smooth-app#2315 (comment)

@stephanegigandet
Copy link
Contributor

The redirection is a bug on the server, I didn't imagine one would issue queries like that. Adding the .json at the end of an URL is more something used for debugging / exploring.

Note that this URL structure works for at most 2 facets (which in this case is ok). It would probably be better to use the search API which allows for unlimited amount of facet and where you won't get those redirections.

https://world.openfoodfacts.org/api/v2/search?informers_tags=monsieurtanuki&states_tags=en:to-be-completed&lc=fr (that's the new version of the search API, but you can do the same thing with the old one as well)

@teolemon
Copy link
Member Author

teolemon commented Jul 4, 2022

@monsieurtanuki the best solution I have right now is using the States taxonomy: https://static.openfoodfacts.org/data/taxonomies/states.json
Otherwise, the tags are stored in https://github.com/openfoodfacts/openfoodfacts-server/blob/e32683cdfdf05b9e83667efaa8494c0dd17e65b4/po/tags/fr.po and not in a structured form

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤳🥫 blocking mobile apps This issues are blocking a feature on the Open Food Facts mobile apps Tags.pm Tags 🧬 Taxonomies https://wiki.openfoodfacts.org/Global_taxonomies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants