{"record":{"id":"1f7efc8c813711d0","repo":"chatboxai/chatbox","slug":"invalid-settings-entry","errorCode":null,"errorMessage":"Invalid settings entry","messagePattern":"Invalid settings entry","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/renderer/packages/backup/import-backup.ts","lineNumber":342,"sourceCode":"      await options.storage.setItemNow(backupSessionStorageKey(session.id), session)\n\n      const meta = restoreSessionMetaResourceKeys(descriptor.meta, resourceKeyMap)\n      const existingMeta = await options.metaStorage.getById(session.id)\n      previousMeta.set(session.id, existingMeta)\n      changedMetaIds.push(session.id)\n      if (existingMeta) await options.metaStorage.update(session.id, meta)\n      else await options.metaStorage.create(meta)\n      options.onProgress?.({\n        phase: 'restoring',\n        current: resourcePlans.length + index + 1,\n        total: resourcePlans.length + manifest.sessions.length,\n        label: session.name,\n      })\n    }\n\n    if (manifest.data.settings) {\n      const value = stagedEntries.get(manifest.data.settings.path)?.value\n      if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid settings entry')\n      await options.storage.setItemNow(\n        BackupStorageKey.Settings,\n        restoreSettingsResourceKeys(value as Partial<Settings>, resourceKeyMap)\n      )\n    }\n    if (manifest.data.copilots) {\n      const value = stagedEntries.get(manifest.data.copilots.path)?.value\n      if (!Array.isArray(value)) throw new Error('Invalid copilots entry')\n      await options.storage.setItemNow(\n        BackupStorageKey.MyCopilots,\n        restoreCopilotResourceKeys(value as CopilotDetail[], resourceKeyMap)\n      )\n    }\n    if (manifest.data.sessionSettings) {\n      const value = stagedEntries.get(manifest.data.sessionSettings.path)?.value\n      if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid session settings entry')\n      const sessionSettings = value as Record<string, unknown>\n      for (const key of [BackupStorageKey.ChatSessionSettings, BackupStorageKey.PictureSessionSettings]) {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/backup/import-backup.ts#L324-L360","documentation":"Thrown when restoring settings if the staged settings.json value is absent, not an object, or an array. Settings must be a JSON object so restoreSettingsResourceKeys can process it. Propagates after rollback.","triggerScenarios":"manifest.data.settings is set, but stagedEntries.get(settings.path).value is null, an array, or a primitive.","commonSituations":"A settings.json hand-edited to an array or scalar; a future format storing settings differently; a truncated or corrupted file.","solutions":["Re-export with a compatible version.","Repair settings.json to be a JSON object.","Remove the settings descriptor from the manifest to skip settings restore (accept losing settings)."],"exampleFix":"// before: non-object settings aborts import\nawait importBackupArchive(file, options)\n// after: validate the settings entry shape before importing\nconst s = parsedSettings\nif (!s || typeof s !== 'object' || Array.isArray(s)) {\n  throw new Error('settings.json must be a JSON object')\n}","handlingStrategy":"type-guard","validationCode":"// Validate the settings entry is a plain object before importing.\nconst s = parsedSettings\nif (!s || typeof s !== 'object' || Array.isArray(s)) {\n  throw new Error('Invalid settings entry')\n}","typeGuard":"// Narrows an unknown value to a non-null, non-array object - the exact check at line 342.\nconst isSettingsEntry = (value: unknown): value is Record<string, unknown> =>\n  Boolean(value) && typeof value === 'object' && !Array.isArray(value)","tryCatchPattern":"try {\n  await importBackupArchive(file, options)\n} catch (error) {\n  if (error instanceof Error && error.message === 'Invalid settings entry') {\n    // Repair settings.json to a JSON object or drop the settings descriptor.\n    throw new Error('settings.json is malformed', { cause: error })\n  }\n  throw error\n}","preventionTips":["Keep settings.json as a JSON object; never an array or scalar.","Re-export with a compatible version instead of hand-editing settings.","Validate staged settings with isSettingsEntry before import."],"tags":["backup","import","settings","schema","validation"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}