Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 from missing table name #184

Closed
earthboundkid opened this issue Jan 26, 2018 · 4 comments
Closed

500 from missing table name #184

earthboundkid opened this issue Jan 26, 2018 · 4 comments

Comments

@earthboundkid
Copy link

earthboundkid commented Jan 26, 2018

datasette/datasette/app.py

Lines 517 to 519 in 56623e4

table_definition = list(await self.execute(name, 'select sql from sqlite_master where name = :n and type="table"', {
'n': table,
}))[0][0]
throws an error if it gets an empty list back. Simplest solution is to write a helper func that just says

result = list(await self.execute(name, sql, params)
if result:
    return result[0][0]

and use it anywhere [0][0] is now.

@simonw
Copy link
Owner

simonw commented Apr 9, 2018

Do you have steps to reproduce here - ideally a small example SQLite database that exhibits the error?

@earthboundkid
Copy link
Author

@simonw
Copy link
Owner

simonw commented Apr 11, 2018

Yuck, nasty - OK I get it, this happens with ANY non-existent table name. Let's fix that - these should clearly return an HTTP 404.

@earthboundkid
Copy link
Author

Reopening this because it still raises 500 for incorrect table capitalization.

Example:

I think because the table name exists but is not in its canonical form, it triggers a dict lookup error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants