datasette / datasette-write-ui

A Datasette plugin that adds UI elements to edit, insert, or delete rows in SQLite tables
Apache License 2.0
15 stars 2 forks source link

500: 'NoneType' object is not subscriptable on edit-row-details #10

Closed simonw closed 11 months ago

simonw commented 11 months ago

Got this error on /-/datasette-write-ui/edit-row-details?db=data&table=chatgpt_conversation&primaryKeys=0133a0e7-2cd8-41c7-914d-e3eb0dd17aeb:

'NoneType' object is not subscriptable

simonw commented 11 months ago

Table schema:

CREATE TABLE chatgpt_conversation (
    id text primary key,
    title text,
    create_time float,
    moderation_results text,
    current_node text,
    plugin_ids text
);
simonw commented 11 months ago

Stack trace:

TypeError: 'NoneType' object is not subscriptable
  File "datasette/app.py", line 1545, in route_path
    response = await view(request, send)
  File "datasette/app.py", line 1727, in async_view_fn
    response = await async_call_with_supported_arguments(
  File "datasette/utils/__init__.py", line 1014, in async_call_with_supported_arguments
    return await fn(*call_with)
  File "__init__.py", line 85, in edit_row_details
    value = row[column["name"]]

And more detail from Sentry:

image
simonw commented 11 months ago

https://github.com/datasette-io/datasette-write-ui/blob/be15b510feea4b33345c790f8eec7fab1b2c25d9/datasette_write_ui/__init__.py#L78-L85

What must have happened is that SQL query returned 0 results, so results.first() returned None.

asg017 commented 11 months ago

I believe the problem here was datasette-write-ui not handling text primary key columns, since it always defaulted to rowid = ?.

The 963c73c should fix this, and was released in 0.0.1a3 . Gonna verify before closing here

asg017 commented 11 months ago

Verified fixed in chat 👍