simonw / datasette-upload-dbs

Upload SQLite database files to Datasette
Apache License 2.0
12 stars 2 forks source link

Interaction with plugins which take actions on first loaded database #5

Closed ocdtrekkie closed 2 years ago

ocdtrekkie commented 2 years ago

I haven't done a truly sanitized test of this yet (just the impacted plugins), but I noticed that after switching my package from running "datasette data.sqlite" to "datasette /folder" format, the app crashes when you try to use a plugin that takes an action on the first-loaded database, such as Upload CSVs. This is what happens when merely selecting Upload CSVs after adding the Upload DBs plugin:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/datasette/app.py", line 1254, in route_path
    response = await view(request, send)
  File "/usr/local/lib/python3.9/dist-packages/datasette/app.py", line 1442, in async_view_fn
    response = await async_call_with_supported_arguments(
  File "/usr/local/lib/python3.9/dist-packages/datasette/utils/__init__.py", line 977, in async_call_with_supported_arguments
    return await fn(*call_with)
  File "/usr/local/lib/python3.9/dist-packages/datasette_upload_csvs/__init__.py", line 46, in upload_csvs
    db = [
IndexError: list index out of range
INFO:     127.0.0.1:46308 - "GET /-/upload-csvs HTTP/1.1" 500 Internal Server Error

The screen when this happens looks like this:

image

I think opening this issue against this plugin as opposed to the CSV one is the right call, because I expect the issue to occur with multiple plugins. (I have not tested it extensively, but I believe datasette-saved-queries just silently fails to create its table, for example.)

I really like the paradigm this plugin creates, which does not require an initial database file, but I suspect it introduced some issues that may need to be addressed across the plugin ecosystem.

simonw commented 2 years ago

Should be fixed in this release: https://github.com/simonw/datasette-upload-csvs/releases/tag/0.8.1

simonw commented 2 years ago

Opened a new Datasette core issue to track this and potentially come up with a more general solution: