chatboxai/chatbox · error
Invalid settings entry
Error message
Invalid settings entry
What it means
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.
Source
Thrown at src/renderer/packages/backup/import-backup.ts:342
await options.storage.setItemNow(backupSessionStorageKey(session.id), session)
const meta = restoreSessionMetaResourceKeys(descriptor.meta, resourceKeyMap)
const existingMeta = await options.metaStorage.getById(session.id)
previousMeta.set(session.id, existingMeta)
changedMetaIds.push(session.id)
if (existingMeta) await options.metaStorage.update(session.id, meta)
else await options.metaStorage.create(meta)
options.onProgress?.({
phase: 'restoring',
current: resourcePlans.length + index + 1,
total: resourcePlans.length + manifest.sessions.length,
label: session.name,
})
}
if (manifest.data.settings) {
const value = stagedEntries.get(manifest.data.settings.path)?.value
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid settings entry')
await options.storage.setItemNow(
BackupStorageKey.Settings,
restoreSettingsResourceKeys(value as Partial<Settings>, resourceKeyMap)
)
}
if (manifest.data.copilots) {
const value = stagedEntries.get(manifest.data.copilots.path)?.value
if (!Array.isArray(value)) throw new Error('Invalid copilots entry')
await options.storage.setItemNow(
BackupStorageKey.MyCopilots,
restoreCopilotResourceKeys(value as CopilotDetail[], resourceKeyMap)
)
}
if (manifest.data.sessionSettings) {
const value = stagedEntries.get(manifest.data.sessionSettings.path)?.value
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid session settings entry')
const sessionSettings = value as Record<string, unknown>
for (const key of [BackupStorageKey.ChatSessionSettings, BackupStorageKey.PictureSessionSettings]) {View on GitHub (pinned to 81571269ad)
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).
Example fix
// before: non-object settings aborts import
await importBackupArchive(file, options)
// after: validate the settings entry shape before importing
const s = parsedSettings
if (!s || typeof s !== 'object' || Array.isArray(s)) {
throw new Error('settings.json must be a JSON object')
} Defensive patterns
Strategy: type-guard
Validate before calling
// Validate the settings entry is a plain object before importing.
const s = parsedSettings
if (!s || typeof s !== 'object' || Array.isArray(s)) {
throw new Error('Invalid settings entry')
} Type guard
// Narrows an unknown value to a non-null, non-array object - the exact check at line 342. const isSettingsEntry = (value: unknown): value is Record<string, unknown> => Boolean(value) && typeof value === 'object' && !Array.isArray(value)
Try / catch
try {
await importBackupArchive(file, options)
} catch (error) {
if (error instanceof Error && error.message === 'Invalid settings entry') {
// Repair settings.json to a JSON object or drop the settings descriptor.
throw new Error('settings.json is malformed', { cause: error })
}
throw error
} Prevention
- 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.
When it happens
Trigger: manifest.data.settings is set, but stagedEntries.get(settings.path).value is null, an array, or a primitive.
Common situations: A settings.json hand-edited to an array or scalar; a future format storing settings differently; a truncated or corrupted file.
Related errors
- Invalid session entry: ${entry.path}
- Invalid copilots entry
- Invalid session settings entry
- Custom provider "${providerId}" conflicts with a builtin pro
- Backup JSON entry is too large: ${path}
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/1f7efc8c813711d0.
Report an issue: GitHub.