chatboxai/chatbox · error
Invalid session settings entry
Error message
Invalid session settings entry
What it means
Thrown when restoring session settings if the staged session-settings.json value is absent, not an object, or an array. It must be an object keyed by BackupStorageKey so its ChatSessionSettings/PictureSessionSettings members can be written. Propagates after rollback.
Source
Thrown at src/renderer/packages/backup/import-backup.ts:358
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]) {
if (key in sessionSettings) await options.storage.setItemNow(key, sessionSettings[key])
}
}
await cleanupTemps()
return {
manifest,
warnings: [...manifest.warnings, ...importWarnings],
restoredSessionCount: manifest.sessions.length,
restoredResourceCount: manifest.resources.length,
}
} catch (error) {
if (commitStarted) await rollback()
await cleanupTemps()
throw error
}View on GitHub (pinned to 81571269ad)
Solutions
- Re-export with a compatible version.
- Repair session-settings.json to be a JSON object.
- Remove the sessionSettings descriptor from the manifest to skip restore.
Example fix
// before: non-object session-settings aborts import
await importBackupArchive(file, options)
// after: validate the session-settings entry shape before importing
const v = parsedSessionSettings
if (!v || typeof v !== 'object' || Array.isArray(v)) {
throw new Error('session-settings.json must be a JSON object')
} Defensive patterns
Strategy: type-guard
Validate before calling
// Validate the session-settings entry is a plain object before importing.
const v = parsedSessionSettings
if (!v || typeof v !== 'object' || Array.isArray(v)) {
throw new Error('Invalid session settings entry')
} Type guard
// Narrows an unknown value to a non-null, non-array object - the exact check at line 358. const isSessionSettingsEntry = (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 session settings entry') {
// Repair session-settings.json to a JSON object or drop the descriptor.
throw new Error('session-settings.json is malformed', { cause: error })
}
throw error
} Prevention
- Keep session-settings.json as a JSON object keyed by BackupStorageKey.
- Re-export with a compatible version instead of hand-editing.
- Validate staged session settings with isSessionSettingsEntry before import.
When it happens
Trigger: manifest.data.sessionSettings is set, but stagedEntries.get(sessionSettings.path).value is null, an array, or a primitive.
Common situations: A corrupted or hand-edited session-settings.json; a format change; a truncated file.
Related errors
- Invalid session entry: ${entry.path}
- Invalid settings entry
- Invalid copilots entry
- Backup JSON entry is too large: ${path}
- Manifest contains a duplicate path: ${descriptor.path}
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/bee2fa134d6e5163.
Report an issue: GitHub.