XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
77 stars 134 forks source link

Misleading error about choices sheet when extension omitted in select_one_from_file #660

Closed lognaturel closed 6 months ago

lognaturel commented 9 months ago

Software and hardware versions

pyxform v1.12.2

Problem description

If select_one_from_file is given an argument without an extension, we get There should be a choices sheet in this xlsform. Please ensure that the choices sheet has the mandatory columns 'list_name', 'name', and 'label'.

Steps to reproduce the problem

Convert a form with a select_one_from_file with an argument without an extension like Bad select one from file.xlsx

Expected behavior

The error should be about specifying the filename extension (e.g. Filename for select_one_from_file "things" should include .csv, .xml or .geojson extension). I think it's reasonable to assume that if an extension isn't specified, the form designer made a mistake (it's rare to save files without extensions).

lindsay-stevens commented 9 months ago

There doesn't seem to be an existing validation check for a missing file extension for select_one_from_file, or select_multiple_from_file. There are mostly implicit checks for invalid extensions. So perhaps this issue is more about adding a new error specifically for missing or invalid extensions.

A minor issue I spotted that could be fixed at the same time is that the existing choices sheet name validation should check for select_multiple_from_file as well as select_one_from_file, on L1124.