fix: gracefully degrade when widget_secret table is missing or access denied
The releases widget was crashing because throwIfActionForbiddenAsync or the widgetSecrets query would throw before DB migrations are run. Wrap in try/catch so the widget works without tokens in that case.
This commit is contained in:
1 file changed
+4
@@ -48,6 +48,7 @@ export const releasesRouter = createTRPCRouter({
|
|||||||
let allowedRepoIds: Set<string> | null = null;
|
let allowedRepoIds: Set<string> | null = null;
|
||||||
|
|
||||||
if (input.itemId) {
|
if (input.itemId) {
|
||||||
|
try {
|
||||||
const item = await ctx.db.query.items.findFirst({ where: eq(items.id, input.itemId) });
|
const item = await ctx.db.query.items.findFirst({ where: eq(items.id, input.itemId) });
|
||||||
if (item && item.kind === "releases") {
|
if (item && item.kind === "releases") {
|
||||||
await throwIfActionForbiddenAsync(ctx, eq(boards.id, item.boardId), "view");
|
await throwIfActionForbiddenAsync(ctx, eq(boards.id, item.boardId), "view");
|
||||||
@@ -69,6 +70,9 @@ export const releasesRouter = createTRPCRouter({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
// Access denied or table not yet migrated -- proceed without tokens
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Promise.all(
|
return await Promise.all(
|
||||||
|
|||||||
Reference in new issue
Block a user