Fix: Handle datasource not exists for query
This commit is contained in:
parent
177c329e69
commit
19b9e593d6
|
@ -20,6 +20,7 @@ const handleError = (e: any, errors?: any) => {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.trace(e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,23 @@ export const backfill = async (appDb: any, timestamp: string | number) => {
|
||||||
const queries: Query[] = await getQueries(appDb)
|
const queries: Query[] = await getQueries(appDb)
|
||||||
|
|
||||||
for (const query of queries) {
|
for (const query of queries) {
|
||||||
const datasource: Datasource = await getDatasource(
|
let datasource: Datasource
|
||||||
appDb,
|
|
||||||
query.datasourceId
|
try {
|
||||||
)
|
datasource = await getDatasource(appDb, query.datasourceId)
|
||||||
|
} catch (e: any) {
|
||||||
|
// handle known bug where a datasource has been deleted
|
||||||
|
// and the query has not
|
||||||
|
if (e.status === 404) {
|
||||||
|
datasource = {
|
||||||
|
_id: query.datasourceId,
|
||||||
|
source: "unknown",
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await events.query.created(datasource, query, timestamp)
|
await events.query.created(datasource, query, timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,9 @@ export const run = async (db: any) => {
|
||||||
if (!allUsers || allUsers.length === 0) {
|
if (!allUsers || allUsers.length === 0) {
|
||||||
// first time startup - we don't need to backfill anything
|
// first time startup - we don't need to backfill anything
|
||||||
// tenant will be identified when admin user is created
|
// tenant will be identified when admin user is created
|
||||||
await events.installation.firstStartup()
|
if (env.SELF_HOSTED) {
|
||||||
|
await events.installation.firstStartup()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue