diff --git a/datasette/app.py b/datasette/app.py index c052be58..6b889f08 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -218,6 +218,8 @@ class Datasette: self.config_dir = config_dir self.pdb = pdb self._secret = secret or secrets.token_hex(32) + if files is not None and isinstance(files, str): + raise ValueError("files= must be a list of paths, not a string") self.files = tuple(files or []) + tuple(immutables or []) if config_dir: db_files = [] diff --git a/tests/test_internals_datasette.py b/tests/test_internals_datasette.py index 1b4732af..e2cb0870 100644 --- a/tests/test_internals_datasette.py +++ b/tests/test_internals_datasette.py @@ -130,7 +130,14 @@ async def test_datasette_ensure_permissions_check_visibility( @pytest.mark.asyncio async def test_datasette_render_template_no_request(): # https://github.com/simonw/datasette/issues/1849 - ds = Datasette([], memory=True) + ds = Datasette(memory=True) await ds.invoke_startup() rendered = await ds.render_template("error.html") assert "Error " in rendered + + +def test_datasette_error_if_string_not_list(tmpdir): + # https://github.com/simonw/datasette/issues/1985 + db_path = str(tmpdir / "data.db") + with pytest.raises(ValueError): + ds = Datasette(db_path)