linshenkx/prompt-optimizer · error · Error

app backup package is missing favorites.json

Error message

app backup package is missing favorites.json

What it means

Thrown by readDataManagerResourcePackage in packages/ui/src/utils/data-manager-resource-package.ts when the zip contains manifest.json and app-data.json but no entry at FAVORITES_JSON_PATH ('favorites.json'). Favorites are a required part of the app backup format, so the reader aborts. It is the last of the three entry-presence checks before parseManifest runs.

Source

Thrown at packages/ui/src/utils/data-manager-resource-package.ts:296

  manifest: DataManagerResourcePackageManifest
  appDataJson: string
  favoritesJson: string
  files: Record<string, Uint8Array>
} => {
  const bytes = input instanceof Uint8Array ? input : new Uint8Array(input)
  const files = unzipSync(bytes)
  const manifestBytes = files['manifest.json']
  const appDataBytes = files[APP_DATA_JSON_PATH]
  const favoritesBytes = files[FAVORITES_JSON_PATH]

  if (!manifestBytes) {
    throw new Error('app backup package is missing manifest.json')
  }
  if (!appDataBytes) {
    throw new Error('app backup package is missing app-data.json')
  }
  if (!favoritesBytes) {
    throw new Error('app backup package is missing favorites.json')
  }

  return {
    manifest: parseManifest(strFromU8(manifestBytes)),
    appDataJson: strFromU8(appDataBytes),
    favoritesJson: strFromU8(favoritesBytes),
    files,
  }
}

const getImportStorageService = (
  store: DataManagerImageStoreKey,
  options: ImportDataManagerResourcePackageOptions,
): Pick<IImageStorageService, 'getImage' | 'saveImage'> | null | undefined =>
  store === 'favoriteImages'
    ? options.favoriteImageStorageService
    : options.imageStorageService

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Confirm favorites.json exists at the zip root; if missing, re-export the backup with the current app version
  2. If you control the exporter, ensure it always writes favorites.json (even an empty favorites array) into the package
  3. Pre-check required entries before calling readDataManagerResourcePackage
  4. For legacy packages without favorites, write a small migration that injects an empty favorites.json before reading

Example fix

// before
const pkg = readDataManagerResourcePackage(bytes) // throws: missing favorites.json

// after (legacy package migration)
const files = unzipSync(bytes)
if (!files['favorites.json']) {
  files['favorites.json'] = strToU8(JSON.stringify({ favorites: [] }))
  bytes = zipSync(files)
}
const pkg = readDataManagerResourcePackage(bytes)
Defensive patterns

Strategy: validation

Validate before calling

import { unzipSync } from 'fflate'

const isCompleteAppBackup = (bytes: Uint8Array): boolean => {
  try {
    const entries = Object.keys(unzipSync(bytes))
    return ['manifest.json', 'app-data.json', 'favorites.json'].every((n) => entries.includes(n))
  } catch {
    return false
  }
}

Try / catch

try {
  const pkg = readDataManagerResourcePackage(bytes)
} catch (e) {
  if (e instanceof Error && e.message.includes('missing favorites.json')) {
    // legacy/partial package: re-export or inject empty favorites
    return
  }
  throw e
}

Prevention

When it happens

Trigger: A zip with manifest.json and app-data.json but no favorites.json entry — e.g. a package built by an older exporter that didn't include favorites, an archive where favorites.json was renamed/removed, or a partial export that finished app-data but not favorites.

Common situations: Version skew between an exporter that omitted favorites and the current reader that requires it; users deleting 'unneeded' files from the archive; re-zip tooling that skips files; truncated downloads.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/ca566e95ed9baeae. Report an issue: GitHub.