{"record":{"id":"eb9b6ac44752188e","repo":"linshenkx/prompt-optimizer","slug":"app-backup-package-is-missing-app-data-json","errorCode":null,"errorMessage":"app backup package is missing app-data.json","messagePattern":"app backup package is missing app-data\\.json","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utils/data-manager-resource-package.ts","lineNumber":293,"sourceCode":"export const readDataManagerResourcePackage = (\n  input: ArrayBuffer | Uint8Array,\n): {\n  manifest: DataManagerResourcePackageManifest\n  appDataJson: string\n  favoritesJson: string\n  files: Record<string, Uint8Array>\n} => {\n  const bytes = input instanceof Uint8Array ? input : new Uint8Array(input)\n  const files = unzipSync(bytes)\n  const manifestBytes = files['manifest.json']\n  const appDataBytes = files[APP_DATA_JSON_PATH]\n  const favoritesBytes = files[FAVORITES_JSON_PATH]\n\n  if (!manifestBytes) {\n    throw new Error('app backup package is missing manifest.json')\n  }\n  if (!appDataBytes) {\n    throw new Error('app backup package is missing app-data.json')\n  }\n  if (!favoritesBytes) {\n    throw new Error('app backup package is missing favorites.json')\n  }\n\n  return {\n    manifest: parseManifest(strFromU8(manifestBytes)),\n    appDataJson: strFromU8(appDataBytes),\n    favoritesJson: strFromU8(favoritesBytes),\n    files,\n  }\n}\n\nconst getImportStorageService = (\n  store: DataManagerImageStoreKey,\n  options: ImportDataManagerResourcePackageOptions,\n): Pick<IImageStorageService, 'getImage' | 'saveImage'> | null | undefined =>\n  store === 'favoriteImages'","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/utils/data-manager-resource-package.ts#L275-L311","documentation":"Thrown by readDataManagerResourcePackage in packages/ui/src/utils/data-manager-resource-package.ts when the zip contains manifest.json but no entry at APP_DATA_JSON_PATH ('app-data.json'). The app data payload is mandatory for restore, so the package is rejected. This check runs after the manifest.json presence check, so the archive is already known to be a plausible backup.","triggerScenarios":"A zip with manifest.json present but app-data.json absent: partially generated packages where the app-data write failed, an archive repacked without the payload file, a renamed or moved app-data.json entry, or a manifest-only zip used as a template.","commonSituations":"Interrupted export (disk full, tab closed) producing a partial zip; manual repackaging that dropped the payload; upload pipeline that filters 'unnecessary' JSON files; filename casing differences introduced by zip tools.","solutions":["Verify the zip contains an 'app-data.json' entry at the root alongside manifest.json","Re-export the backup from the source app rather than repairing a partial package","If the export was interrupted, discard the file and retry the export to get a complete archive","Pre-validate entries before calling readDataManagerResourcePackage and surface a file-picker error to the user"],"exampleFix":"// before\nconst pkg = readDataManagerResourcePackage(bytes) // throws: missing app-data.json\n\n// after\nconst names = Object.keys(unzipSync(bytes))\nfor (const required of ['manifest.json', 'app-data.json', 'favorites.json']) {\n  if (!names.includes(required)) throw new Error(`Backup incomplete: no ${required}`)\n}\nconst pkg = readDataManagerResourcePackage(bytes)","handlingStrategy":"validation","validationCode":"import { unzipSync } from 'fflate'\n\nconst REQUIRED = ['manifest.json', 'app-data.json', 'favorites.json'] as const\n\nconst hasAllEntries = (bytes: Uint8Array): boolean => {\n  try {\n    const entries = Object.keys(unzipSync(bytes))\n    return REQUIRED.every((name) => entries.includes(name))\n  } catch {\n    return false\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const pkg = readDataManagerResourcePackage(bytes)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('missing app-data.json')) {\n    // treat as incomplete/corrupt export; ask user to re-export\n    return\n  }\n  throw e\n}","preventionTips":["Pre-validate all three required entries before restore","Don't attempt to repair partial packages; re-export instead","Ensure exports complete atomically (write zip last) so partial files are less common","Warn users when downloads are interrupted (size/content-type checks)"],"tags":["zip","missing-file","backup-restore","partial-export"],"backgroundTag":"zip-missing-entry","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}