openfoodfacts/openfoodfacts-server
View on GitHubEmpty search produces weird download
Open
#9,312 opened on Nov 13, 2023
good first issue馃攷 Search
Description
What
When search.pl doesn't find any products, the CSV and XLSX are weird. Basically, HTTP response seems to contain some header for the resulting format, and the search result page that says "no results".
Steps to reproduce the behavior
- Go to https://world-de.openfoodfacts.org/cgi/search.pl?action=process&tagtype_0=brands&tag_contains_0=does_not_contain&tag_0=M%C3%BCller&tagtype_1=brands&tag_contains_1=contains&tag_1=Muller&sort_by=unique_scans_n&page_size=20 to search for products that have the brand "Muller" but not the brand "M眉ller"
- Notice that there are no results aside: Notice that pagination is presented, and one counter says there are 44 products, while another one shows 0 products.
- Download the search results in XLSX and CSV format
- Open the downloaded files in a text editor.
Expected behavior
An empty CSV/XLSX file should be provided for download.
Why
The downloads are provided with content-disposition: attachment;filename=openfoodfacts_export.xlsx or content-disposition: attachment;filename=openfoodfacts_export.csv headers. Users trying to open the files could get confused.