{"record":{"id":"9e2734750eea86c6","repo":"SillyTavern/SillyTavern","slug":"failed-to-get-settings-snapshots","errorCode":null,"errorMessage":"Failed to get settings snapshots","messagePattern":"Failed to get settings snapshots","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"public/scripts/user.js","lineNumber":547,"sourceCode":"/**\n * Gets a list of settings snapshots.\n * @returns {Promise<Snapshot[]>} List of snapshots\n * @typedef {Object} Snapshot\n * @property {string} name Snapshot name\n * @property {number} date Date in milliseconds\n * @property {number} size File size in bytes\n */\nasync function getSnapshots() {\n    try {\n        const response = await fetch('/api/settings/get-snapshots', {\n            method: 'POST',\n            headers: getRequestHeaders({ omitContentType: true }),\n        });\n\n        if (!response.ok) {\n            const data = await response.json();\n            toastr.error(data.error || 'Unknown error', 'Failed to get settings snapshots');\n            throw new Error('Failed to get settings snapshots');\n        }\n\n        const snapshots = await response.json();\n        return snapshots;\n    } catch (error) {\n        console.error('Error getting settings snapshots:', error);\n        return [];\n    }\n}\n\n/**\n * Make a snapshot of the current settings.\n * @param {function} callback Success callback\n * @returns {Promise<void>}\n */\nasync function makeSnapshot(callback) {\n    try {\n        const response = await fetch('/api/settings/make-snapshot', {","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/public/scripts/user.js#L529-L565","documentation":"Thrown by `getSnapshots` after POST `/api/settings/get-snapshots` returns a non-ok response. Notably the catch returns `[]`, so callers receive an empty list rather than seeing the error. The request uses `omitContentType: true`.","triggerScenarios":"Backend endpoint error; permissions denied on the snapshots directory; session expired; misconfigured content-type header rejected by middleware.","commonSituations":"Snapshots feature disabled or misconfigured; deployment where the endpoint is not registered; silent failure mistaken for 'no snapshots'.","solutions":["Confirm `/api/settings/get-snapshots` is registered and returns 200.","Check server logs since the empty-array fallback hides the real error.","Verify session validity and directory permissions."],"exampleFix":"// before\nconst snaps = await getSnapshots(); // silent [] on error\n// after\nconst r = await fetch('/api/settings/get-snapshots', { method: 'POST', headers: getRequestHeaders({ omitContentType: true }) });\nif (!r.ok) console.error('snapshots failed', await r.json());","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let snaps = []; try { snaps = await getSnapshots(); } catch (e) { console.error(e); }","preventionTips":["Remember getSnapshots swallows errors and returns [].","Log separately if an empty list is unexpected so silent failures surface.","Verify the endpoint and directory permissions during setup."],"tags":["network","api","settings","snapshot"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}