{"record":{"id":"9844b9640706a744","repo":"SillyTavern/SillyTavern","slug":"not-found-9844b9","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"src/endpoints/themes.js","lineNumber":30,"sourceCode":"        return response.sendStatus(400);\n    }\n\n    const filename = path.join(request.user.directories.themes, sanitize(`${request.body.name}.json`));\n    writeFileAtomicSync(filename, JSON.stringify(request.body, null, 4), 'utf8');\n\n    return response.sendStatus(200);\n});\n\nrouter.post('/delete', (request, response) => {\n    if (!request.body || !request.body.name) {\n        return response.sendStatus(400);\n    }\n\n    try {\n        const filename = path.join(request.user.directories.themes, sanitize(`${request.body.name}.json`));\n        if (!fs.existsSync(filename)) {\n            console.error('Theme file not found:', filename);\n            return response.sendStatus(404);\n        }\n        fs.unlinkSync(filename);\n        return response.sendStatus(200);\n    } catch (error) {\n        console.error(error);\n        return response.sendStatus(500);\n    }\n});\n","sourceCodeStart":12,"sourceCodeEnd":39,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/src/endpoints/themes.js#L12-L39","documentation":"POST /api/themes/delete returns 404 'Not Found' when the resolved theme file does not exist on disk (fs.existsSync is false). The name was provided and valid, but no matching <name>.json lives in the user's themes directory.","triggerScenarios":"Client requests deletion of a theme whose file is already gone, renamed, or whose name does not exactly match a file in the themes directory.","commonSituations":"Theme was already deleted but the UI list is stale; name casing/whitespace mismatch; file moved manually outside the app; concurrent delete by another session.","solutions":["Refresh the theme list in the UI and retry against a currently-listed theme.","Verify the exact name spelling and case against the themes directory contents.","Treat a 404 on delete as a success if the goal is simply 'ensure it is gone'."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Only delete themes that currently appear in the fetched list\nconst list = await fetchThemeList();\nif (!list.includes(name)) { console.info('Theme already absent'); return; }","typeGuard":null,"tryCatchPattern":"// Treat 404 on delete as idempotent success\nconst res = await fetch('/api/themes/delete', opts);\nif (res.status === 404) { console.info('Theme not present; nothing to delete'); return; }\nif (!res.ok) throw new Error('Delete failed');","preventionTips":["Refresh the theme list before deleting.","Match the name exactly (case-sensitive) against the listed file.","Treat a 404 on delete as success when the goal is 'ensure removed'."],"tags":["themes","not-found","filesystem"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}