chatboxai/chatbox · error · Error

Attachment did not produce any retrievable chunks

Error message

Attachment did not produce any retrievable chunks

What it means

Thrown after buildAttachmentChunks runs when either parents or children arrays are empty. Chunking produced no retrievable units, so embedding would be meaningless. The check is parents.length === 0 || children.length === 0.

Source

Thrown at src/main/session-attachment-rag/file-loaders.ts:112

  const attachment = await ensureAttachmentNotCanceled(attachmentId)
  log.debug(
    `${SESSION_ATTACHMENT_RAG_LOG_PREFIX} [FILE] Begin processing attachment: id=${attachment.id}, file="${attachment.filename}", parser=${attachment.parserType ?? 'unknown'}, storageKey=${attachment.attachmentStorageKey}`
  )

  const content = await getStoreBlob(attachment.attachmentStorageKey)
  if (!content?.trim()) {
    throw new Error('Attachment content not found or empty')
  }

  const chunkingPipeline = selectAttachmentChunkingPipeline(attachment.filename)
  await updateSessionAttachmentIndexingProgress(attachmentId, {
    indexingStage: 'chunking',
    totalChunks: 0,
    embeddedChunks: 0,
  })
  const { parents, children } = await buildAttachmentChunks(content, attachment.filename)
  if (parents.length === 0 || children.length === 0) {
    throw new Error('Attachment did not produce any retrievable chunks')
  }
  await ensureAttachmentNotCanceled(attachmentId)
  log.debug(
    `${SESSION_ATTACHMENT_RAG_LOG_PREFIX} [FILE] Chunking completed: attachmentId=${attachment.id}, pipeline=${chunkingPipeline}, parents=${parents.length}, children=${children.length}`
  )

  const parentIdMap = await replaceAttachmentParentsAndChunks(
    attachment.id,
    parents.map((parent) => ({
      parentOrder: parent.parentOrder,
      sectionPath: parent.sectionPath,
      docType: attachment.mimeType,
      text: parent.text,
      tokenEstimate: parent.tokenEstimate,
      charCount: parent.charCount,
    })),
    children.map((child) => ({
      parentOrder: child.parentOrder,

View on GitHub (pinned to 81571269ad)

Solutions

  1. Inspect selectAttachmentChunkingPipeline(filename) and the parser output for the offending file to see why extraction yielded nothing.
  2. For scanned PDFs, run OCR first or reject them at upload with a clear message.
  3. Lower the minimum-chunk-size threshold or split overly-large min sizes so small valid content still produces one chunk.
  4. If a parser returns no text, mark the attachment failed with 'could not extract text' instead of the generic chunking error.

Example fix

// before
if (parents.length === 0 || children.length === 0) throw new Error('Attachment did not produce any retrievable chunks')

// after: report which side failed and the parser used
if (parents.length === 0 || children.length === 0) {
  throw new Error(`Attachment produced no retrievable chunks (parents=${parents.length}, children=${children.length}, pipeline=${chunkingPipeline})`)
}
Defensive patterns

Strategy: validation

Validate before calling

if (!content.trim()) { /* handled by [89] */ }
const sample = content.slice(0, 1000)
if (!sample.replace(/\s/g, '')) { await markSessionAttachmentFailed(id, 'no extractable text'); return }

Type guard

function isNoChunks(e: unknown): e is Error { return e instanceof Error && e.message === 'Attachment did not produce any retrievable chunks' }

Try / catch

// the outer processing loop marks the attachment failed; enrich the message with pipeline/parser info before surfacing.

Prevention

When it happens

Trigger: A file whose content (after selectAttachmentChunkingPipeline) yields zero chunks: e.g. a binary/non-text file misclassified as text, a PDF whose text extraction returned nothing, a markdown file containing only frontmatter with no body, or a chunking config whose min-size threshold exceeds the entire content.

Common situations: Scanned PDF with no OCR text layer; image-only file with a text mime type; chunking min chunk size larger than document; parser returned content that the chunker strips entirely (e.g. only whitespace after normalization).

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/b01958feaf6effb4. Report an issue: GitHub.