Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix: change error when section for item not found to logged warning and remove item (#2044)

Meier Lukasb413e2ec7dd3
diff --git a/packages/old-import/src/mappers/map-item.ts b/packages/old-import/src/mappers/map-item.ts
index 2b11118be..a4faeed58 100644
--- a/packages/old-import/src/mappers/map-item.ts
+++ b/packages/old-import/src/mappers/map-item.ts
@@ -15,7 +15,7 @@ export const mapApp = (
boardSize: BoardSize,
appsMap: Map<string, { id: string }>,
sectionMap: Map<string, { id: string }>,
-): InferInsertModel<typeof items> => {
+): InferInsertModel<typeof items> | null => {
if (app.area.type === "sidebar") throw new Error("Mapping app in sidebar is not supported");
const shapeForSize = app.shape[boardSize];
@@ -25,7 +25,8 @@ export const mapApp = (
const sectionId = sectionMap.get(app.area.properties.id)?.id;
if (!sectionId) {
- throw new Error(`Failed to find section for app appId='${app.id}' sectionId='${app.area.properties.id}'`);
+ logger.warn(`Failed to find section for app appId='${app.id}' sectionId='${app.area.properties.id}'. Removing app`);
+ return null;
}
return {
@@ -69,9 +70,10 @@ export const mapWidget = (
const sectionId = sectionMap.get(widget.area.properties.id)?.id;
if (!sectionId) {
- throw new Error(
- `Failed to find section for widget widgetId='${widget.id}' sectionId='${widget.area.properties.id}'`,
+ logger.warn(
+ `Failed to find section for widget widgetId='${widget.id}' sectionId='${widget.area.properties.id}'. Removing widget`,
);
+ return null;
}
return {
diff --git a/packages/old-import/src/prepare/prepare-items.ts b/packages/old-import/src/prepare/prepare-items.ts
index e82d6043c..b099433cf 100644
--- a/packages/old-import/src/prepare/prepare-items.ts
+++ b/packages/old-import/src/prepare/prepare-items.ts
@@ -10,5 +10,5 @@ export const prepareItems = (
) =>
widgets
.map((widget) => mapWidget(widget, boardSize, appsMap, sectionMap))
- .filter((widget) => widget !== null)
- .concat(apps.map((app) => mapApp(app, boardSize, appsMap, sectionMap)));
+ .concat(apps.map((app) => mapApp(app, boardSize, appsMap, sectionMap)))
+ .filter((widget) => widget !== null);