Skip to content

catalog_databases does not clear out stale entries, causing 500 error on / #2605

@simonw

Description

@simonw

If your internal.db is persistent and it has records in catalog_databases for databases that are no longer attached you get a 500 KeyError on the index page thanks to this code:

db_page = await self.ds.allowed_resources(
"view-database", request.actor, include_is_private=True
)
allowed_databases = [r async for r in db_page.all()]
allowed_db_dict = {r.parent: r for r in allowed_databases}
# Group tables by database
tables_by_db = {}
table_page = await self.ds.allowed_resources(
"view-table", request.actor, include_is_private=True
)
async for t in table_page.all():
if t.parent not in tables_by_db:
tables_by_db[t.parent] = {}
tables_by_db[t.parent][t.child] = t
databases = []
# Iterate over allowed databases instead of all databases
for name in allowed_db_dict.keys():
db = self.ds.databases[name]

Solution: make sure to wipe catalog_database first at startup.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions