Skip to content

Certain database names results in 404: "Database not found: None" #1181

@jieter

Description

@jieter

I have a file named test-database (1).sqlite. When requesting the home route /, I see datasette is able to read it correctly:

Screenshot 2021-01-07 at 12 54 46

However, if I click any of the links, datasette replies with: Error 404 Database not found: None

It seems the hash is crucial, as renaming the file to database (1).sqlite makes the error go away.

This lines checks for a single dash:

if db_name not in self.ds.databases and "-" in db_name:

$ datasette test-database\ \(1\).sqlite 
INFO:     Started server process [68314]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)
INFO:     127.0.0.1:54043 - "GET /favicon.ico HTTP/1.1" 200 OK
INFO:     127.0.0.1:54043 - "GET / HTTP/1.1" 200 OK
...
INFO:     127.0.0.1:54044 - "GET /favicon.ico HTTP/1.1" 200 OK
INFO:     127.0.0.1:54044 - "GET /test-database (1) HTTP/1.1" 404 Not Found

Version:

$ datasette --version
datasette, version 0.53

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions