{"record":{"id":"99568a3d53c43e0c","repo":"chatboxai/chatbox","slug":"backup-entry-is-too-large-entry-path","errorCode":null,"errorMessage":"Backup entry is too large: ${entry.path}","messagePattern":"Backup entry is too large: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/export-backup.ts","lineNumber":115,"sourceCode":"  const bytes = new TextEncoder().encode(JSON.stringify(value))\n  if (bytes.length > MAX_BACKUP_JSON_ENTRY_BYTES) throw new Error(`Backup JSON entry is too large: ${path}`)\n  return {\n    archive: { path, data: bytes, compress: true },\n    descriptor: { path, size: bytes.length, checksum: await sha256Checksum(bytes) },\n  }\n}\n\nasync function* enforceArchiveLimits(\n  entries: AsyncIterable<ZipArchiveEntry>\n): AsyncGenerator<ZipArchiveEntry, void, unknown> {\n  let entryCount = 0\n  let totalUncompressedBytes = 0\n  for await (const entry of entries) {\n    entryCount++\n    if (entryCount > DEFAULT_ZIP_LIMITS.maxEntries) throw new Error('Backup contains too many entries')\n    const maxEntryBytes = backupEntryByteLimit(entry.path)\n    if (entry.data instanceof Uint8Array) {\n      if (entry.data.length > maxEntryBytes) throw new Error(`Backup entry is too large: ${entry.path}`)\n      totalUncompressedBytes += entry.data.length\n      if (totalUncompressedBytes > DEFAULT_ZIP_LIMITS.maxTotalUncompressedBytes) {\n        throw new Error('Backup uncompressed size exceeds the safety limit')\n      }\n      yield entry\n      continue\n    }\n    let entryBytes = 0\n    const data = entry.data\n    yield {\n      ...entry,\n      data: (async function* () {\n        for await (const chunk of data) {\n          entryBytes += chunk.length\n          totalUncompressedBytes += chunk.length\n          if (entryBytes > maxEntryBytes) throw new Error(`Backup entry is too large: ${entry.path}`)\n          if (totalUncompressedBytes > DEFAULT_ZIP_LIMITS.maxTotalUncompressedBytes) {\n            throw new Error('Backup uncompressed size exceeds the safety limit')","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/export-backup.ts#L97-L133","documentation":"Thrown by enforceArchiveLimits() in the Uint8Array branch when a single in-memory entry's data.length exceeds the per-entry byte limit returned by backupEntryByteLimit(path) — 128 MiB for JSON paths, 512 MiB for resource paths. This is the per-entry size guard for entries already fully materialized in memory, complementing the streaming branch checks (118/119).","triggerScenarios":"An entry whose data is a Uint8Array (already buffered) exceeds its path-specific limit. JSON entries (jsonEntry) are always Uint8Array and checked at 114 first, so this branch typically catches resource entries loaded into memory (e.g. a 600 MiB image). The path determines the limit via isBackupJsonPath.","commonSituations":"A session references a very large image or attachment that is loaded into memory as a single Uint8Array; a resource path is misclassified so it gets the wrong limit; corrupted resource metadata inflates a single blob.","solutions":["Identify the oversized resource (entry.path) and remove or shrink it before exporting.","Stream the large resource instead of buffering it as a Uint8Array so it hits the streaming branch (118) which enforces the same limit incrementally.","Raise MAX_BACKUP_RESOURCE_ENTRY_BYTES only if the resources are legitimately large and memory allows."],"exampleFix":"// before\nif (entry.data.length > maxEntryBytes) throw new Error(`Backup entry is too large: ${entry.path}`)\n\n// after — include sizes for diagnosis\nif (entry.data.length > maxEntryBytes) {\n  throw new Error(`Backup entry is too large: ${entry.path} (${entry.data.length} > ${maxEntryBytes} bytes)`)\n}","handlingStrategy":"validation","validationCode":"function entryWithinLimit(path: string, data: Uint8Array): boolean {\n  const limit = backupEntryByteLimit(path)\n  return data.length <= limit\n}\nif (!entryWithinLimit(entry.path, entry.data)) {\n  throw new Error(`Entry ${entry.path} exceeds its size limit`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await exportBackup({ items: ['conversations'] })\n} catch (error) {\n  if (error instanceof Error && /Backup entry is too large/i.test(error.message)) {\n    showToast(`A resource is too large: ${extractPath(error.message)}. Remove it and retry.`)\n  } else throw error\n}","preventionTips":["Stream large resources instead of buffering them as Uint8Array so the streaming limit check (118) applies incrementally.","Shrink or remove oversized resources before exporting.","Verify resource path classification so the correct (json/resource) limit applies."],"tags":["backup","export","size-limit","zip","resource"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}