chatboxai/chatbox · error · Error

Attachment content not found or empty

Error message

Attachment content not found or empty

What it means

Thrown by processAttachment when getStoreBlob(attachment.attachmentStorageKey) returns null/undefined or a string that is empty/whitespace-only after trim(). It is the first content sanity check before chunking begins. Storage is addressed by attachmentStorageKey, so a missing key or empty blob both surface here.

Source

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

      const message = error instanceof Error ? error.message : String(error)
      log.warn(
        `${SESSION_ATTACHMENT_RAG_LOG_PREFIX} [FILE] Retrying embedding batch after transient error (attempt ${attempt}/${EMBEDDING_MAX_RETRIES}): ${message}`
      )
      await setTimeout(EMBEDDING_RETRY_DELAY_MS * attempt)
    }
  }
}

async function processAttachment(attachmentId: number) {
  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(

View on GitHub (pinned to 81571269ad)

Solutions

  1. Verify the blob exists in object storage under attachmentStorageKey before triggering processing.
  2. If the blob is genuinely empty, mark the attachment failed with a user-facing 'file is empty' message rather than retrying.
  3. Re-upload the attachment to regenerate the blob if retention deleted it.
  4. Distinguish null vs whitespace-only to give a sharper error (null = missing key, whitespace = empty file).

Example fix

// before
if (!content?.trim()) throw new Error('Attachment content not found or empty')

// after: split the two cases
if (content == null) throw new Error(`Attachment blob missing for key ${attachment.attachmentStorageKey}`)
if (!content.trim()) throw new Error('Attachment file is empty')
Defensive patterns

Strategy: validation

Validate before calling

const blob = await getStoreBlob(attachment.attachmentStorageKey)
if (blob == null) { await markSessionAttachmentFailed(id, 'blob missing'); return }
if (!blob.trim()) { await markSessionAttachmentFailed(id, 'file is empty'); return }

Type guard

function isAttachmentContentEmpty(e: unknown): e is Error { return e instanceof Error && e.message === 'Attachment content not found or empty' }

Try / catch

// processAttachment's outer loop already catches and marks the attachment failed; ensure the message is stored on the row for user-facing display.

Prevention

When it happens

Trigger: attachmentStorageKey points at an object store entry that was deleted/expired; the upload completed but the blob write failed silently; the blob exists but contains only whitespace (e.g. a blank text file); the storage backend returned null for a transient outage.

Common situations: Blob retention policy cleaned up the attachment's underlying object; file upload interrupted so the blob row exists but content is empty; encrypted blob could not be decrypted and was stored as ''; storage key mis-formed (wrong prefix/bucket).

Related errors


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