{"record":{"id":"5e18be7a3ad096ca","repo":"janhq/jan","slug":"file-f-name-exceeds-size-limit-f-size-byt","errorCode":null,"errorMessage":"File '${f.name}' exceeds size limit (${f.size} bytes > ${maxSize} MB).","messagePattern":"File '(.+?)' exceeds size limit \\((.+?) bytes > (.+?) MB\\)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/rag-extension/src/index.ts","lineNumber":402,"sourceCode":"      ExtensionTypeEnum.VectorDB\n    ) as unknown as VectorDBExtension\n    if (!vec?.ingestFileForProject) {\n      throw new Error('Vector DB extension does not support project-level ingestion')\n    }\n\n    // Load settings\n    const s = this.config\n    const maxSize = (s?.enabled === false ? 0 : s?.maxFileSizeMB) || undefined\n    const chunkSize = s?.chunkSizeChars as number | undefined\n    const chunkOverlap = s?.overlapChars as number | undefined\n\n    let totalChunks = 0\n    const processedFiles: AttachmentFileInfo[] = []\n\n    for (const f of files) {\n      if (!f?.path) continue\n      if (maxSize && f.size && f.size > maxSize * 1024 * 1024) {\n        throw new Error(\n          `File '${f.name}' exceeds size limit (${f.size} bytes > ${maxSize} MB).`\n        )\n      }\n\n      const fileName = f.name || f.path.split(/[\\\\/]/).pop()\n      const info = await (vec as VectorDBExtension).ingestFileForProject(\n        projectId,\n        { path: f.path, name: fileName, type: f.type, size: f.size },\n        { chunkSize: chunkSize ?? 512, chunkOverlap: chunkOverlap ?? 64 }\n      )\n      totalChunks += Number(info?.chunk_count || 0)\n      processedFiles.push(info)\n    }\n\n    return {\n      filesProcessed: processedFiles.length,\n      chunksInserted: totalChunks,\n      files: processedFiles,","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/extensions/rag-extension/src/index.ts#L384-L420","documentation":"Thrown by RAGExtension.ingestAttachmentsForProject() inside the per-file loop when a file's size in bytes exceeds config.maxFileSizeMB (converted to bytes via *1024*1024). The guard only fires when both maxSize and f.size are truthy, so files of unknown size are allowed through. It is a hard stop on the whole batch, not a per-file skip.","triggerScenarios":"Attaching a file larger than the configured maxFileSizeMB to a project; maxFileSizeMB was lowered in settings but large attachments remain; a multi-file batch where one early file is oversized aborts the entire ingest.","commonSituations":"Default size cap too low for a large PDF/dataset; user changed the setting without realizing it caps attachments; bulk upload where one oversized file blocks the rest.","solutions":["Increase config.maxFileSizeMB (RAG setting max_file_size_mb) to accommodate the file.","Filter or split the oversized file before attaching (compress PDF, chunk the document).","Pre-filter the files array to skip oversized entries instead of letting the loop throw.","Set f.size accurately so the cap is enforced against real sizes, not 0/undefined."],"exampleFix":"// before\nawait rag.ingestAttachmentsForProject(projectId, files)\n\n// after\nconst maxBytes = config.maxFileSizeMB * 1024 * 1024\nconst safe = files.filter((f) => !f.size || f.size <= maxBytes)\nconst rejected = files.filter((f) => f.size && f.size > maxBytes)\nif (rejected.length) logger.warn('Skipped oversized:', rejected)\nawait rag.ingestAttachmentsForProject(projectId, safe)","handlingStrategy":"validation","validationCode":"const maxBytes = (config.maxFileSizeMB ?? Infinity) * 1024 * 1024\nconst oversized = files.filter((f) => f.size && f.size > maxBytes)\nif (oversized.length) {\n  // drop them, or raise a single aggregated message\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter the file list by size before calling ingestAttachmentsForProject.","Surface the cap in the UI file picker so users do not select oversized files.","Keep f.size populated; unknown-size files bypass the check."],"tags":["rag","validation","file-size","config","project"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}