simonw / datasette-graphql

Datasette plugin providing an automatic GraphQL API for your SQLite databases
https://datasette-graphql-demo.datasette.io/
Apache License 2.0
101 stars 6 forks source link

500 error on _csv_progress_ table page #90

Closed simonw closed 2 years ago

simonw commented 2 years ago

Seeing this error when running datasette-graphql in conjunction with datasette-upload-csvs:

KeyError: '_csv_progress_'
  File "datasette/app.py", line 1263, in route_path
    response = await view(request, send)
  File "datasette/views/base.py", line 134, in view
    return await self.dispatch_request(request)
  File "datasette/views/base.py", line 91, in dispatch_request
    return await handler(request)
  File "datasette/views/base.py", line 507, in get
    r = await self.render(templates, request=request, context=context)
  File "datasette/views/base.py", line 121, in render
    await self.ds.render_template(
  File "datasette/app.py", line 1006, in render_template
    return await template.render_async(template_context)
  File "jinja2/environment.py", line 1312, in render_async
    return self.environment.handle_exception()
  File "jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "jinja2/environment.py", line 1310, in <listcomp>
    return concat([n async for n in self.root_render_func(ctx)])  # type: ignore
  File "/usr/local/lib/python3.10/site-packages/datasette/templates/table.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/templates/base.html", line 1, in top-level template code
    {% extends "default:base.html" %}
  File "/usr/local/lib/python3.10/site-packages/datasette/templates/base.html", line 60, in top-level template code
    {% block content %}
  File "/usr/local/lib/python3.10/site-packages/datasette/templates/table.html", line 30, in block 'content'
    {% set links = table_actions() %}{% if links %}
  File "jinja2/async_utils.py", line 56, in auto_await
    return await t.cast("t.Awaitable[V]", value)
  File "datasette/views/table.py", line 716, in table_actions
    extra_links = await await_me_maybe(hook)
  File "datasette/utils/__init__.py", line 111, in await_me_maybe
    value = await value
  File "__init__.py", line 215, in inner
    example_query = await db_schema.table_classes[table].example_query()
simonw commented 2 years ago

Weirdly I have been unable to recreate the error locally. Here's the exact database which is exhibiting the error in my production Datasette instance - 36KB: https://static.simonwillison.net/static/2022/issue90.db

I have not been able to replicate the bug.

simonw commented 2 years ago

I've spent enough time on this that I'm frustrated and just want a fix out. I'm going to teach this line to do nothing if it gets a KeyError:

example_query = await db_schema.table_classes[table].example_query()