Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(api): an unknown or private share answers 404, not a server error

Carl-Gerhard Lindesvärd54c8e35d8b9a
diff --git a/packages/core/src/modules/share/share.service.ts b/packages/core/src/modules/share/share.service.ts
index 482f954d6..3d7b95767 100644
--- a/packages/core/src/modules/share/share.service.ts
+++ b/packages/core/src/modules/share/share.service.ts
@@ -93,7 +93,7 @@ export async function validateReportAccess(
});
if (!share?.public) {
- throw new Error('Share not found or not public');
+ throw new TRPCNotFoundError('Share not found or not public');
}
if (!share.dashboard.reports.some((r) => r.id === reportId)) {
@@ -109,7 +109,7 @@ export async function validateReportAccess(
});
if (!share?.public) {
- throw new Error('Share not found or not public');
+ throw new TRPCNotFoundError('Share not found or not public');
}
if (share.reportId !== reportId) {
@@ -146,7 +146,7 @@ export async function validateShareAccess(
dashboardShare.dashboard.reports.length > 0
) {
if (!dashboardShare.public) {
- throw new Error('Share not found or not public');
+ throw new TRPCNotFoundError('Share not found or not public');
}
const projectId = dashboardShare.projectId;
@@ -174,7 +174,7 @@ export async function validateShareAccess(
if (reportShare) {
if (!reportShare.public) {
- throw new Error('Share not found or not public');
+ throw new TRPCNotFoundError('Share not found or not public');
}
const projectId = reportShare.projectId;
@@ -195,7 +195,7 @@ export async function validateShareAccess(
return { projectId, isValid: hasCookie || !!hasMemberAccess };
}
- throw new Error('Share not found');
+ throw new TRPCNotFoundError('Share not found');
}
export async function validateOverviewShareAccess(
@@ -215,7 +215,7 @@ export async function validateOverviewShareAccess(
});
if (!share?.public) {
- throw new Error('Share not found or not public');
+ throw new TRPCNotFoundError('Share not found or not public');
}
if (share.projectId !== projectId) {