openfoodfacts/openfoodfacts-server

Empty search produces weird download

Open

#9,312 opened on Nov 13, 2023

View on GitHub
聽(7 comments)聽(0 reactions)聽(0 assignees)Perl聽(477 stars)聽(236 forks)batch import
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

  1. 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"
  2. 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.
  3. Download the search results in XLSX and CSV format
  4. 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.

Contributor guide

Empty search produces weird download 路 openfoodfacts/openfoodfacts-server#9312 | Good First Issue