simonw / datasette

An open source multi-tool for exploring and publishing data
https://datasette.io
Apache License 2.0
9.06k stars 648 forks source link

'Datasette' object has no attribute 'table_metadata' #2316

Open andig opened 2 months ago

andig commented 2 months ago

After importing a new table I'm getting

'Datasette' object has no attribute 'table_metadata'

when starting datasette and browsing to table. This is the backtrace:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/app.py", line 1668, in route_path
    response = await view(request, send)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/app.py", line 1861, in async_view_fn
    response = await async_call_with_supported_arguments(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/utils/__init__.py", line 1021, in async_call_with_supported_arguments
    return await fn(*call_with)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/views/table.py", line 747, in table_view
    response = await table_view_traced(datasette, request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/views/table.py", line 897, in table_view_traced
    await datasette.render_template(
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/app.py", line 1352, in render_template
    return await template.render_async(template_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/jinja2/environment.py", line 1324, in render_async
    return self.environment.handle_exception()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/templates/table.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/templates/base.html", line 62, in top-level template code
    {% block content %}
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/templates/table.html", line 27, in block 'content'
    {% set action_links, action_title = actions(), "View actions" if is_view else "Table actions" %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/jinja2/async_utils.py", line 65, in auto_await
    return await t.cast("t.Awaitable[V]", value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/views/table.py", line 1420, in actions
    extra_links = await await_me_maybe(hook)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/utils/__init__.py", line 115, in await_me_maybe
    value = await value
            ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette_graphql/__init__.py", line 235, in inner
    db_schema = await schema_for_database_via_cache(datasette, database=database)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette_graphql/utils.py", line 81, in schema_for_database_via_cache
    schema = await schema_for_database(datasette, database)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette_graphql/utils.py", line 97, in schema_for_database
    table_metadata = await db.execute_fn(
                     ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/database.py", line 282, in execute_fn
    return await asyncio.get_event_loop().run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette/database.py", line 280, in in_thread
    return fn(conn)
           ^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette_graphql/utils.py", line 98, in <lambda>
    lambda conn: introspect_tables(conn, datasette, db.name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/datasette/0.64.6_2/libexec/lib/python3.12/site-packages/datasette_graphql/utils.py", line 672, in introspect_tables
    datasette_table_metadata = datasette.table_metadata(
                               ^^^^^^^^^^^^^^^^^^^^^^^^

Not sure what makes this specific table different from the others?

andig commented 2 months ago

Anything I can contribute to diagnose/fix this? Right now datasette (installed via Homebrew) is useless as it crashes on almost any table.

tddschn commented 2 months ago

Got the same error.

simonw commented 2 months ago

This looks like a bug in the GraphQL plugin. I'll take a look tomorrow.

andig commented 2 months ago

Would be great to get this fixed as it makes datasette unusable in this case.

andig commented 2 months ago

@simonw any update? I'm totally blocked on using datasette due to this error.

andig commented 1 month ago

Friendly ping :)

andig commented 1 week ago

Friendly ping :)