janhq/jan · error · Error

File ' ' exceeds size limit ( bytes > MB).

Error message

File '${f.name}' exceeds size limit (${f.size} bytes > ${maxSize} MB).

What it means

The RAG extension throws this when an attachment file being ingested via ingestAttachmentsForProject is larger than the configured per-file size limit (maxFileSizeMB, in MB). The check converts maxSize from MB to bytes and compares against f.size. It is a guard against ingesting oversized documents into the vector DB.

Solutions

  1. Increase maxFileSizeMB in the RAG extension settings to cover the file being attached
  2. Compress or split the oversized file before ingestion
  3. Set maxSize to 0 / disable the size limit in settings if large files are acceptable
  4. Skip or surface the offending file in the UI before calling ingestAttachmentsForProject

Example fix

// before
await rag.ingestAttachmentsForProject(projectId, files) // throws for big files
// after
const limitMb = (rag.settings?.maxFileSizeMB ?? 10)
const allowed = files.filter(f => !f.size || f.size <= limitMb * 1024 * 1024)
await rag.ingestAttachmentsForProject(projectId, allowed)
Defensive patterns

Strategy: validation

Validate before calling

const maxSizeMb = 10 // or from settings
const tooBig = files.filter(f => f.size && f.size > maxSizeMb * 1024 * 1024)
if (tooBig.length) {
  throw new Error(`Files exceed ${maxSizeMb}MB limit: ${tooBig.map(f => f.name).join(', ')}`)
}

Type guard

const isWithinSizeLimit = (f, maxMb) => Boolean(f?.path) && (!f.size || f.size <= maxMb * 1024 * 1024)

Prevention

When it happens

Trigger: Calling ingestAttachmentsForProject with a file whose f.size exceeds maxSize*1024*1024 bytes while maxSize (from extension settings maxFileSizeMB) is set and non-zero.

Common situations: Users attach large PDFs/videos to a project; default or configured maxFileSizeMB is small (e.g. 5-10MB); a settings update lowered the limit while old large files remain.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17). Data as JSON: /api/errors/5e18be7a3ad096ca. Report an issue: GitHub.

Appendix: source

Thrown at extensions/rag-extension/src/index.ts:402

      ExtensionTypeEnum.VectorDB
    ) as unknown as VectorDBExtension
    if (!vec?.ingestFileForProject) {
      throw new Error('Vector DB extension does not support project-level ingestion')
    }

    // Load settings
    const s = this.config
    const maxSize = (s?.enabled === false ? 0 : s?.maxFileSizeMB) || undefined
    const chunkSize = s?.chunkSizeChars as number | undefined
    const chunkOverlap = s?.overlapChars as number | undefined

    let totalChunks = 0
    const processedFiles: AttachmentFileInfo[] = []

    for (const f of files) {
      if (!f?.path) continue
      if (maxSize && f.size && f.size > maxSize * 1024 * 1024) {
        throw new Error(
          `File '${f.name}' exceeds size limit (${f.size} bytes > ${maxSize} MB).`
        )
      }

      const fileName = f.name || f.path.split(/[\\/]/).pop()
      const info = await (vec as VectorDBExtension).ingestFileForProject(
        projectId,
        { path: f.path, name: fileName, type: f.type, size: f.size },
        { chunkSize: chunkSize ?? 512, chunkOverlap: chunkOverlap ?? 64 }
      )
      totalChunks += Number(info?.chunk_count || 0)
      processedFiles.push(info)
    }

    return {
      filesProcessed: processedFiles.length,
      chunksInserted: totalChunks,
      files: processedFiles,

View on GitHub (pinned to 7205d770c1)