Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/api/plane/utils/content_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def validate_binary_data(data):
"style",
"start",
"type",
"xmlns",
# common editor data-* attributes seen in stored HTML
# (wildcards like data-* are NOT supported by nh3; we add known keys
# here and dynamically include all data-* seen in the input below)
Expand Down
16 changes: 13 additions & 3 deletions apps/live/src/extensions/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import { getPageService } from "@/services/page/handler";
// type
import type { FetchPayloadWithContext, StorePayloadWithContext } from "@/types";

const normalizeToError = (error: unknown, fallbackMessage: string) => {
if (error instanceof Error) {
return error;
}

const message = typeof error === "string" && error.trim().length > 0 ? error : fallbackMessage;

return new Error(message);
};

const fetchDocument = async ({ context, documentName: pageId }: FetchPayloadWithContext) => {
try {
const service = getPageService(context.documentType, context);
Expand All @@ -29,7 +39,7 @@ const fetchDocument = async ({ context, documentName: pageId }: FetchPayloadWith
return binaryData;
} catch (error) {
logger.error("Error in fetching document", error);
throw error;
throw normalizeToError(error, `Failed to fetch document: ${pageId}`);
}
};

Expand All @@ -45,10 +55,10 @@ const storeDocument = async ({ context, state: pageBinaryData, documentName: pag
description_html: contentHTML,
description: contentJSON,
};
return service.updateDescriptionBinary(pageId, payload);
await service.updateDescriptionBinary(pageId, payload);
} catch (error) {
logger.error("Error in updating document:", error);
throw error;
throw normalizeToError(error, `Failed to update document: ${pageId}`);
}
};

Expand Down
4 changes: 2 additions & 2 deletions apps/live/src/services/page/core.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
throw error;
});
}

async fetchDescriptionBinary(pageId: string): Promise<any> {

Check warning on line 28 in apps/live/src/services/page/core.service.ts

View workflow job for this annotation

GitHub Actions / Build and lint web apps

Unexpected any. Specify a different type
return this.get(`${this.basePath}/pages/${pageId}/description/`, {
headers: {
...this.getHeader(),
Expand All @@ -35,7 +35,7 @@
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
throw error;
});
}

Expand Down Expand Up @@ -87,7 +87,7 @@
}
}

async updateDescriptionBinary(pageId: string, data: TPageDescriptionPayload): Promise<any> {

Check warning on line 90 in apps/live/src/services/page/core.service.ts

View workflow job for this annotation

GitHub Actions / Build and lint web apps

Unexpected any. Specify a different type
return this.patch(`${this.basePath}/pages/${pageId}/description/`, data, {
headers: this.getHeader(),
})
Expand Down
Loading