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.

Update CSV import handling: Adjust error handling for missing files, increase max row limit, and clarify batch size comment.

Kiran K5d8c673ad1a1
diff --git a/apps/web/app/(ee)/api/cron/import/csv/route.ts b/apps/web/app/(ee)/api/cron/import/csv/route.ts
index 57e0b2f04e..fdf206bdf0 100644
--- a/apps/web/app/(ee)/api/cron/import/csv/route.ts
+++ b/apps/web/app/(ee)/api/cron/import/csv/route.ts
@@ -67,7 +67,7 @@ export async function POST(req: Request) {
const payload = payloadSchema.parse(JSON.parse(rawBody));
const { workspaceId, id } = payload;
const redisKey = `import:csv:${workspaceId}:${id}`;
- const BATCH_SIZE = 100; // Process 500 links at a time
+ const BATCH_SIZE = 100;
const rows = await redis.lpop<Record<string, string>[]>(
`${redisKey}:rows`,
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/import/csv/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/import/csv/route.ts
index be7c8e8923..3c116ce12b 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/import/csv/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/import/csv/route.ts
@@ -1,3 +1,4 @@
+import { DubApiError } from "@/lib/api/errors";
import { withWorkspace } from "@/lib/auth";
import { qstash } from "@/lib/cron";
import { verifyFolderAccess } from "@/lib/folder/permissions";
@@ -15,7 +16,10 @@ export const POST = withWorkspace(async ({ req, workspace, session }) => {
const folderId = formData.get("folderId") as string | null;
if (!file) {
- return NextResponse.json({ error: "No file provided" }, { status: 400 });
+ throw new DubApiError({
+ code: "bad_request",
+ message: "No CSV file was provided.",
+ });
}
if (folderId) {
diff --git a/apps/web/ui/modals/import-csv-modal/select-file.tsx b/apps/web/ui/modals/import-csv-modal/select-file.tsx
index f5c9dfc43b..c14287a502 100644
--- a/apps/web/ui/modals/import-csv-modal/select-file.tsx
+++ b/apps/web/ui/modals/import-csv-modal/select-file.tsx
@@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
import { Controller } from "react-hook-form";
import { useCsvContext } from ".";
-const MAX_ROWS_LIMIT = 10000;
+const MAX_ROWS_LIMIT = 50000;
export function SelectFile() {
const { watch, control, fileColumns, setFileColumns, setFirstRows } =
@@ -26,7 +26,7 @@ export function SelectFile() {
.then((rowCount) => {
if (rowCount > MAX_ROWS_LIMIT) {
setError(
- "CSV file exceeds the maximum limit of 50,000 rows. Please split the file into multiple files and upload them separately.",
+ `CSV file exceeds the maximum limit of ${MAX_ROWS_LIMIT.toLocaleString()} rows. Please split the file into multiple files and upload them separately.`,
);
setFileColumns(null);
setFirstRows(null);