{"record":{"id":"b01958feaf6effb4","repo":"chatboxai/chatbox","slug":"attachment-did-not-produce-any-retrievable-chunks","errorCode":null,"errorMessage":"Attachment did not produce any retrievable chunks","messagePattern":"Attachment did not produce any retrievable chunks","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/session-attachment-rag/file-loaders.ts","lineNumber":112,"sourceCode":"  const attachment = await ensureAttachmentNotCanceled(attachmentId)\n  log.debug(\n    `${SESSION_ATTACHMENT_RAG_LOG_PREFIX} [FILE] Begin processing attachment: id=${attachment.id}, file=\"${attachment.filename}\", parser=${attachment.parserType ?? 'unknown'}, storageKey=${attachment.attachmentStorageKey}`\n  )\n\n  const content = await getStoreBlob(attachment.attachmentStorageKey)\n  if (!content?.trim()) {\n    throw new Error('Attachment content not found or empty')\n  }\n\n  const chunkingPipeline = selectAttachmentChunkingPipeline(attachment.filename)\n  await updateSessionAttachmentIndexingProgress(attachmentId, {\n    indexingStage: 'chunking',\n    totalChunks: 0,\n    embeddedChunks: 0,\n  })\n  const { parents, children } = await buildAttachmentChunks(content, attachment.filename)\n  if (parents.length === 0 || children.length === 0) {\n    throw new Error('Attachment did not produce any retrievable chunks')\n  }\n  await ensureAttachmentNotCanceled(attachmentId)\n  log.debug(\n    `${SESSION_ATTACHMENT_RAG_LOG_PREFIX} [FILE] Chunking completed: attachmentId=${attachment.id}, pipeline=${chunkingPipeline}, parents=${parents.length}, children=${children.length}`\n  )\n\n  const parentIdMap = await replaceAttachmentParentsAndChunks(\n    attachment.id,\n    parents.map((parent) => ({\n      parentOrder: parent.parentOrder,\n      sectionPath: parent.sectionPath,\n      docType: attachment.mimeType,\n      text: parent.text,\n      tokenEstimate: parent.tokenEstimate,\n      charCount: parent.charCount,\n    })),\n    children.map((child) => ({\n      parentOrder: child.parentOrder,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/main/session-attachment-rag/file-loaders.ts#L94-L130","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Inspect selectAttachmentChunkingPipeline(filename) and the parser output for the offending file to see why extraction yielded nothing.","For scanned PDFs, run OCR first or reject them at upload with a clear message.","Lower the minimum-chunk-size threshold or split overly-large min sizes so small valid content still produces one chunk.","If a parser returns no text, mark the attachment failed with 'could not extract text' instead of the generic chunking error."],"exampleFix":"// before\nif (parents.length === 0 || children.length === 0) throw new Error('Attachment did not produce any retrievable chunks')\n\n// after: report which side failed and the parser used\nif (parents.length === 0 || children.length === 0) {\n  throw new Error(`Attachment produced no retrievable chunks (parents=${parents.length}, children=${children.length}, pipeline=${chunkingPipeline})`)\n}","handlingStrategy":"validation","validationCode":"if (!content.trim()) { /* handled by [89] */ }\nconst sample = content.slice(0, 1000)\nif (!sample.replace(/\\s/g, '')) { await markSessionAttachmentFailed(id, 'no extractable text'); return }","typeGuard":"function isNoChunks(e: unknown): e is Error { return e instanceof Error && e.message === 'Attachment did not produce any retrievable chunks' }","tryCatchPattern":"// the outer processing loop marks the attachment failed; enrich the message with pipeline/parser info before surfacing.","preventionTips":["OCR scanned PDFs before indexing.","Reject image-only files with text mime types at upload.","Tune minimum-chunk-size so small but valid content still yields one chunk."],"tags":["session-attachment-rag","chunking","validation","typescript"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}