Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Link upsert guardrails

Steven Tey34a364dce7fc
diff --git a/apps/web/app/api/links/upsert/route.ts b/apps/web/app/api/links/upsert/route.ts
index 983727694c..fdca254581 100644
--- a/apps/web/app/api/links/upsert/route.ts
+++ b/apps/web/app/api/links/upsert/route.ts
@@ -22,6 +22,14 @@ export const PUT = withWorkspace(
const bodyRaw = await parseRequestBody(req);
const body = createLinkBodySchema.parse(bodyRaw);
+ if (workspace.totalLinks > 100000) {
+ throw new DubApiError({
+ code: "forbidden",
+ message:
+ "Link upserts are not recommended for workspaces with more than 100,000 links. Try doing GET `/links/info` + POST `/links` instead.",
+ });
+ }
+
const link = await prisma.link.findFirst({
where: {
projectId: workspace.id,