janhq/jan · error · Error

File '${f.name}' exceeds size limit (${f.size} bytes > ${max

Error message

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

What it means

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.

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 fad3f12a14)

Solutions

  1. Increase config.maxFileSizeMB (RAG setting max_file_size_mb) to accommodate the file.
  2. Filter or split the oversized file before attaching (compress PDF, chunk the document).
  3. Pre-filter the files array to skip oversized entries instead of letting the loop throw.
  4. Set f.size accurately so the cap is enforced against real sizes, not 0/undefined.

Example fix

// before
await rag.ingestAttachmentsForProject(projectId, files)

// after
const maxBytes = config.maxFileSizeMB * 1024 * 1024
const safe = files.filter((f) => !f.size || f.size <= maxBytes)
const rejected = files.filter((f) => f.size && f.size > maxBytes)
if (rejected.length) logger.warn('Skipped oversized:', rejected)
await rag.ingestAttachmentsForProject(projectId, safe)
Defensive patterns

Strategy: validation

Validate before calling

const maxBytes = (config.maxFileSizeMB ?? Infinity) * 1024 * 1024
const oversized = files.filter((f) => f.size && f.size > maxBytes)
if (oversized.length) {
  // drop them, or raise a single aggregated message
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/5e18be7a3ad096ca. Report an issue: GitHub.