SillyTavern/SillyTavern · error

Bad Request

Error message

Bad Request

What it means

Error "Bad Request" thrown in SillyTavern/SillyTavern.

Source

Thrown at src/endpoints/backgrounds.js:70

        const imageFolderMap = {};
        for (const [relativePath, meta] of Object.entries(index.images)) {
            if (Array.isArray(meta.folderIds) && meta.folderIds.length > 0) {
                // Strip the directory prefix to get just the filename
                const filename = relativePath.split('/').pop() || relativePath;
                imageFolderMap[filename] = meta.folderIds;
            }
        }

        response.json({ folders, imageFolderMap });
    } catch (error) {
        console.error('[Backgrounds] Folders endpoint error:', error);
        response.status(500).json({ error: 'Internal server error.' });
    }
});

router.post('/delete', getFileNameValidationFunction('bg'), async function (request, response) {
    try {
        if (!request.body) return response.sendStatus(400);

        if (request.body.bg !== sanitize(request.body.bg)) {
            console.error('Malicious bg name prevented');
            return response.sendStatus(403);
        }

        const fileName = path.join(request.user.directories.backgrounds, sanitize(request.body.bg));

        if (!fs.existsSync(fileName)) {
            console.error('BG file not found');
            return response.sendStatus(400);
        }

        fs.unlinkSync(fileName);
        invalidateThumbnail(request.user.directories, 'bg', request.body.bg);

        // Remove metadata for deleted image
        const relativePath = path.join('backgrounds', request.body.bg);

View on GitHub (pinned to 8172dcd0ee)

Solutions

  1. Send a request body containing the bg filename to delete.
  2. Provide a valid background filename that exists in the backgrounds folder.

When it happens

Trigger: Thrown at src/endpoints/backgrounds.js:70 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of SillyTavern/SillyTavern@8172dcd0ee (2026-08-13). Data as JSON: /api/errors/e5fff15dcd78bdd2. Report an issue: GitHub.