chatboxai/chatbox · warning · FilePreprocessFailure

empty_attachment_content

empty_attachment_content

Error message

empty_attachment_content

What it means

FilePreprocessFailure with code empty_attachment_content, thrown from parseFileWithLocalFallback when the local parser returned no readable text and Chatbox AI fallback is disabled/unavailable. The check uses hasParsedText(result.content); empty or whitespace-only content with no fallback path yields this specific code so the UI can explain that the file has no extractable text.

Source

Thrown at src/renderer/stores/sessionHelpers.ts:421

function shouldFallbackToChatboxAI(options: LocalParserFallbackOptions): boolean {
  return (
    Boolean(options.forceChatboxAIFallback) || (options.allowChatboxAIFallback !== false && canFallbackToChatboxAI())
  )
}

async function parseFileWithLocalFallback(
  file: File,
  uniqKey: string,
  options: LocalParserFallbackOptions = {}
): Promise<{ content: string; storageKey: string; tokenCountMap: Record<string, number>; parserType: string }> {
  try {
    const result = await parseFileWithLocalParser(file, uniqKey)
    if (!hasParsedText(result.content)) {
      if (shouldFallbackToChatboxAI(options)) {
        return await fallbackToChatboxAIParser(file, uniqKey, 'empty_content')
      }
      throw new FilePreprocessFailure(
        EMPTY_ATTACHMENT_CONTENT_ERROR,
        'local_parse',
        new Error('Local parser returned empty content')
      )
    }
    return result
  } catch (error) {
    log.error(`Local parsing failed for "${file.name}":`, error)

    // Already classified (e.g. a storage-quota failure from the empty-content cloud
    // fallback above) — propagate as-is instead of re-classifying or retrying.
    if (error instanceof FilePreprocessFailure) {
      throw error
    }

    // Encrypted or oversized PDFs cannot be recovered by the cloud parser either,
    // so surface the specific error directly instead of wasting a fallback upload.
    const errorCode = error instanceof Error ? error.message : ''

View on GitHub (pinned to 81571269ad)

Solutions

  1. Enable Chatbox AI cloud fallback so empty local results retry with the cloud OCR-capable parser.
  2. Inform the user the file has no extractable text and suggest OCR/vision-capable model.
  3. Pre-screen attachments for known empty-content cases (zero-byte, image-only PDFs).
  4. Verify canFallbackToChatboxAI() returns true when a license and connectivity are present.

Example fix

// before
if (!hasParsedText(result.content)) {
  if (shouldFallbackToChatboxAI(options)) {
    return await fallbackToChatboxAIParser(file, uniqKey, 'empty_content')
  }
  throw new FilePreprocessFailure(EMPTY_ATTACHMENT_CONTENT_ERROR, 'local_parse', new Error('Local parser returned empty content'))
}
// after
if (!hasParsedText(result.content)) {
  if (shouldFallbackToChatboxAI(options)) {
    return await fallbackToChatboxAIParser(file, uniqKey, 'empty_content')
  }
  throw new FilePreprocessFailure(EMPTY_ATTACHMENT_CONTENT_ERROR, 'local_parse', new Error('Local parser returned empty content'))
}
Defensive patterns

Strategy: fallback

Validate before calling

const result = await parseFileWithLocalParser(file, uniqKey)
if (!hasParsedText(result.content) && !shouldFallbackToChatboxAI(options)) {
  // will throw empty_attachment_content; consider enabling fallback
}

Type guard

function isEmptyAttachmentFailure(e: unknown): boolean {
  return e instanceof Error && (e as { code?: string }).code === 'empty_attachment_content'
}

Try / catch

try {
  return await parseFileWithLocalFallback(file, uniqKey, options)
} catch (err) {
  if (isEmptyAttachmentFailure(err)) {
    notifyUser('This file has no extractable text. Try an OCR-capable model or cloud parser.')
    return null
  }
  throw err
}

Prevention

When it happens

Trigger: Local parse succeeded (isSupported true, key present) but the extracted content is empty/blank: scanned PDF without OCR, image-only PDF, empty file, or a binary file the parser read as zero text. shouldFallbackToChatboxAI(options) is false (fallback disabled or canFallbackToChatboxAI() false).

Common situations: User attaches a scanned document or image-heavy PDF to a model that lacks OCR, an empty file, or cloud fallback turned off (offline, no license, admin-disabled).

Related errors


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