fix: gracefully skip widgets with unknown kind instead of crashing (#5915)
This commit is contained in:
1 parent
b3cdab579b
commit
484b8cf9f1
1 file changed
+19
-17
@@ -1604,22 +1604,24 @@ const getFullBoardWithWhereAsync = async (db: Database, where: SQL<unknown>, use
|
|||||||
collapsed: collapseStates.at(0)?.collapsed ?? false,
|
collapsed: collapseStates.at(0)?.collapsed ?? false,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
items: items.map(({ integrations: itemIntegrations, ...item }) =>
|
items: items
|
||||||
parseItem({
|
.map(({ integrations: itemIntegrations, ...item }) =>
|
||||||
...item,
|
parseItem({
|
||||||
layouts: item.layouts.map((layout) => ({
|
...item,
|
||||||
xOffset: layout.xOffset,
|
layouts: item.layouts.map((layout) => ({
|
||||||
yOffset: layout.yOffset,
|
xOffset: layout.xOffset,
|
||||||
width: layout.width,
|
yOffset: layout.yOffset,
|
||||||
height: layout.height,
|
width: layout.width,
|
||||||
layoutId: layout.layoutId,
|
height: layout.height,
|
||||||
sectionId: layout.sectionId,
|
layoutId: layout.layoutId,
|
||||||
})),
|
sectionId: layout.sectionId,
|
||||||
integrationIds: itemIntegrations.map((item) => item.integration.id),
|
})),
|
||||||
advancedOptions: superjson.parse<BoardItemAdvancedOptions>(item.advancedOptions),
|
integrationIds: itemIntegrations.map((item) => item.integration.id),
|
||||||
options: superjson.parse<Record<string, unknown>>(item.options),
|
advancedOptions: superjson.parse<BoardItemAdvancedOptions>(item.advancedOptions),
|
||||||
}),
|
options: superjson.parse<Record<string, unknown>>(item.options),
|
||||||
),
|
}),
|
||||||
|
)
|
||||||
|
.filter((item) => item !== null),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1635,7 +1637,7 @@ const parseItem = (item: unknown) => {
|
|||||||
const result = outputItemSchema.safeParse(item);
|
const result = outputItemSchema.safeParse(item);
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
throw new Error(result.error.message);
|
return null;
|
||||||
}
|
}
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user