From 0a2b1839b5ba5e33c5ae3fd2c423c1b1185bb215 Mon Sep 17 00:00:00 2001 From: SahilKumar000 Date: Fri, 17 Oct 2025 12:44:30 +0530 Subject: [PATCH 1/2] fix(zip-upload): increased limit for upload --- server/api/knowledgeBase.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/api/knowledgeBase.ts b/server/api/knowledgeBase.ts index 1a1a8eec2..3f74c1d39 100644 --- a/server/api/knowledgeBase.ts +++ b/server/api/knowledgeBase.ts @@ -106,7 +106,7 @@ const { JwtPayloadKey } = config // Storage configuration for Knowledge Base feature files const KB_STORAGE_ROOT = join(process.cwd(), "storage", "kb_files") const MAX_FILE_SIZE = 100 // 100MB max file size -const MAX_ZIP_FILE_SIZE = 25 // 25MB max zip file size +const MAX_ZIP_FILE_SIZE = 35 // 25MB max zip file size // Initialize storage directory for Knowledge Base files ;(async () => { @@ -524,7 +524,6 @@ export const GetCollectionNameForSharedAgentApi = async (c: Context) => { agentExternalId, user.workspaceId, ) - if (!agent) { throw new HTTPException(404, { message: "Agent not found" }) @@ -1212,7 +1211,7 @@ export const UploadFilesApi = async (c: Context) => { const file = files[i] const ext = extname(file.name).toLowerCase() - if (ext === '.zip') { + if (ext === ".zip") { // Check zip file size before extraction const zipSizeMB = Math.round(file.size / 1024 / 1024) if (file.size > MAX_ZIP_FILE_SIZE * 1024 * 1024) { @@ -1220,7 +1219,7 @@ export const UploadFilesApi = async (c: Context) => { `Zip file too large: ${file.name} (${zipSizeMB}MB). Maximum is ${MAX_ZIP_FILE_SIZE}MB`, ) throw new HTTPException(400, { - message: `Zip file too large (${zipSizeMB}MB). Maximum size is ${MAX_ZIP_FILE_SIZE}MB` + message: `Zip file too large (${zipSizeMB}MB). Maximum size is ${MAX_ZIP_FILE_SIZE}MB`, }) } @@ -1287,7 +1286,7 @@ export const UploadFilesApi = async (c: Context) => { paths = extractedPaths // Validate file count - allow up to 3000 files for zip extractions - const maxFilesLimit = 3000 + const maxFilesLimit = 10000 if (files.length > maxFilesLimit) { throw new HTTPException(400, { @@ -1332,7 +1331,7 @@ export const UploadFilesApi = async (c: Context) => { let storagePath = "" try { // Validate file size - try{ + try { checkFileSize(file.size, MAX_FILE_SIZE) } catch (error) { uploadResults.push({ @@ -1742,7 +1741,7 @@ export const DeleteItemApi = async (c: Context) => { } catch (error) { loggerWithChild({ email: userEmail }).error( `Failed to delete file from Vespa: ${id}`, - { error: getErrorMessage(error) } + { error: getErrorMessage(error) }, ) } } @@ -1937,7 +1936,11 @@ export const GetChunkContentApi = async (c: Context) => { const chunkContent = resp.fields.chunks[index] let pageIndex: number | undefined - const isSheetFile = getFileType({ type: resp.fields.mimeType || "", name: resp.fields.fileName || "" }) === FileType.SPREADSHEET + const isSheetFile = + getFileType({ + type: resp.fields.mimeType || "", + name: resp.fields.fileName || "", + }) === FileType.SPREADSHEET if (isSheetFile) { const sheetIndexMatch = docId.match(/_sheet_(\d+)$/) if (sheetIndexMatch) { @@ -1952,7 +1955,7 @@ export const GetChunkContentApi = async (c: Context) => { ? pageNums[0] : 0 } - + if (!chunkContent) { throw new HTTPException(404, { message: "Chunk content not found" }) } From 543c6ab84911b728f073f0dec5042add22e82022 Mon Sep 17 00:00:00 2001 From: Junaid <88700111+junaid-shirur@users.noreply.github.com> Date: Fri, 17 Oct 2025 13:18:13 +0530 Subject: [PATCH 2/2] Fix MAX_ZIP_FILE_SIZE comment for clarity --- server/api/knowledgeBase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/api/knowledgeBase.ts b/server/api/knowledgeBase.ts index 3f74c1d39..fa0a61510 100644 --- a/server/api/knowledgeBase.ts +++ b/server/api/knowledgeBase.ts @@ -106,7 +106,7 @@ const { JwtPayloadKey } = config // Storage configuration for Knowledge Base feature files const KB_STORAGE_ROOT = join(process.cwd(), "storage", "kb_files") const MAX_FILE_SIZE = 100 // 100MB max file size -const MAX_ZIP_FILE_SIZE = 35 // 25MB max zip file size +const MAX_ZIP_FILE_SIZE = 35 // 35MB max zip file size // Initialize storage directory for Knowledge Base files ;(async () => {