chatboxai/chatbox · warning · Error

Managed resource exceeds the backup size limit

Error message

Managed resource exceeds the backup size limit

What it means

Thrown when an encoded resource blob's byte length exceeds MAX_BACKUP_RESOURCE_ENTRY_BYTES (512 MiB, defined in types.ts). encodeStoredBlob produces the bytes that would be written into the archive; exceeding the cap would make the archive unwieldy and risk memory exhaustion, so the entry is rejected. Caught in the resource loop (lines 352-359) and recorded as a 'resource-read-failed' warning, so export continues without that resource.

Source

Thrown at src/renderer/packages/backup/export-backup.ts:305

    }

    const resourceCandidateEntries = Array.from(resourceCandidates.entries())
    for (let index = 0; index < resourceCandidateEntries.length; index++) {
      throwIfAborted(options.signal)
      const [storageKey, candidate] = resourceCandidateEntries[index]
      options.onProgress?.({
        phase: 'resources',
        current: index,
        total: resourceCandidateEntries.length,
        label: candidate.references.find((reference) => reference.filename)?.filename,
      })
      try {
        const storedValue = await options.storage.getBlob(storageKey)
        if (storedValue === null) throw new Error('Managed resource is missing from blob storage')
        const firstReference = candidate.references[0]
        const encoded = encodeStoredBlob(storedValue, firstReference)
        if (encoded.bytes.length > MAX_BACKUP_RESOURCE_ENTRY_BYTES) {
          throw new Error('Managed resource exceeds the backup size limit')
        }
        const checksum = await sha256Checksum(encoded.bytes)
        successfullyReadResourceKeys++
        const dedupeKey = `${checksum.value}:${encoded.encoding}:${encoded.mimeType}`
        const existingResource = deduplicatedResources.get(dedupeKey)
        const sessionIds = unique(
          candidate.references.flatMap((reference) => (reference.sessionId ? [reference.sessionId] : []))
        )
        if (existingResource) {
          existingResource.originalStorageKeys.push(storageKey)
          existingResource.sessionIds = unique([...existingResource.sessionIds, ...sessionIds])
          const candidateScope = resolveResourceScope(candidate)
          if (
            existingResource.scope !== candidateScope ||
            (existingResource.scope === 'session' && existingResource.sessionIds.length !== 1)
          ) {
            existingResource.scope = 'shared'
          }

View on GitHub (pinned to 81571269ad)

Solutions

  1. Reduce the size of the offending resource before exporting (compress, resize, or transcode it).
  2. Remove the large attachment from its session.
  3. Raise MAX_BACKUP_RESOURCE_ENTRY_BYTES in types.ts only after confirming the writer and memory budget can handle larger entries.
  4. Exclude the conversations containing the oversized resource from exportItems.

Example fix

// before: oversized blob silently dropped during export
const blob = await storage.getBlob(key)
// after: downsize or reject before it ever reaches export
if (blob && base64ToBytes(blob).length > MAX_BACKUP_RESOURCE_ENTRY_BYTES) {
  await shrinkOrRemoveAttachment(key)
}
await exportBackupArchive(options)
Defensive patterns

Strategy: validation

Validate before calling

// Before export, flag any managed blob that will exceed the resource cap once encoded.
import { MAX_BACKUP_RESOURCE_ENTRY_BYTES } from './types'
import { base64ToBytes } from './codec'
const oversized: string[] = []
for (const key of managedResourceKeys) {
  const blob = await storage.getBlob(key)
  if (blob && base64ToBytes(blob).length > MAX_BACKUP_RESOURCE_ENTRY_BYTES) oversized.push(key)
}

Type guard

// True when the blob's decoded size fits the resource entry budget.
const withinResourceBudget = (decodedBytes: number): boolean =>
  decodedBytes <= MAX_BACKUP_RESOURCE_ENTRY_BYTES

Prevention

When it happens

Trigger: A single managed resource - image, parsed/raw attachment, parsed link, tool result, avatar, background, or copilot image - once encoded (utf8 or data-url-base64) is larger than 512 MiB.

Common situations: A user attached a very large video or raw file; a parsed attachment expanded an enormous document; base64 encoding of a binary blob pushed an already-large file over the cap.

Related errors


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