openfoodfacts/openfoodfacts-server

Empty search produces weird download

Open

#9,312 opened on 2023年11月13日

GitHub で見る
 (7 comments) (0 reactions) (0 assignees)Perl (477 stars) (236 forks)batch import
good first issue🔎 Search

説明

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.

コントリビューターガイド

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