openfoodfacts/openfoodfacts-server

Empty search produces weird download

Open

#9,312 创建于 2023年11月13日

在 GitHub 查看
 (7 评论) (0 反应) (0 负责人)Perl (477 star) (236 fork)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.

贡献者指南