SillyTavern/SillyTavern · warning
No path specified
Error message
No path specified
What it means
400 validation failure in POST /api/images/delete. The handler requires request.body.path to be truthy before it will resolve or delete anything. Sending no path field, an empty string, or null short-circuits here. This is a client-contract error, not a server fault.
Source
Thrown at src/endpoints/images.js:136
if (!fs.existsSync(directoryPath)) {
fs.mkdirSync(directoryPath, { recursive: true });
}
const folders = fs.readdirSync(directoryPath, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
return response.send(folders);
} catch (error) {
console.error(error);
return response.status(500).send({ error: 'Unable to retrieve folders' });
}
});
router.post('/delete', async (request, response) => {
try {
if (!request.body.path) {
return response.status(400).send('No path specified');
}
const pathToDelete = path.join(request.user.directories.root, request.body.path);
if (!isPathUnderParent(request.user.directories.userImages, pathToDelete)) {
return response.status(400).send('Invalid path');
}
if (!fs.existsSync(pathToDelete)) {
return response.status(404).send('File not found');
}
fs.unlinkSync(pathToDelete);
console.info(`Deleted image: ${request.body.path} from ${request.user.profile.handle}`);
return response.sendStatus(200);
} catch (error) {
console.error(error);
return response.sendStatus(500);
}View on GitHub (pinned to 8172dcd0ee)
Solutions
- On the client, confirm the selected image's relative path is attached as `path` in the JSON body before firing the request.
- Add a client-side guard that disables the delete button until a path is selected, preventing the empty-body request entirely.
- Inspect the outgoing request payload in the browser network tab to confirm `path` is present and non-empty.
Example fix
// before: fires regardless of selection
deleteImage();
// after: guard before sending
if (!selectedImagePath) { return; }
await fetch('/api/images/delete', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ path: selectedImagePath }),
}); Defensive patterns
Strategy: validation
Validate before calling
// Client-side: never send the delete request without a path
function buildDeleteBody(path) {
if (typeof path !== 'string' || path.trim().length === 0) {
throw new Error('path is required and must be a non-empty string');
}
return JSON.stringify({ path });
} Type guard
/** @param {unknown} p @returns {p is string} */
function isNonEmptyPath(p) {
return typeof p === 'string' && p.trim().length > 0;
} Prevention
- Disable the delete control until a path is selected.
- Use the exact path string returned by /list or /upload; do not synthesize it.
- Add a unit test that the client always attaches `path` to delete requests.
- Validate with a shared schema (e.g. zod) on both client and server.
When it happens
Trigger: POST /api/images/delete with an empty body, a body where `path` is omitted, set to '', null, or 0. Typically a client that forgot to attach the selected file's path, or a deserialization bug that drops the field.
Common situations: Frontend bug that sends the delete request before populating the path; JSON.stringify of an undefined value yielding an empty object; a bulk-delete refactor that no longer threads the per-item path through.
Related errors
- Error: no response body detected
- Error: invalid name.
- Error: no avatar_url in request body
- Error: character file does not exist
- Error: cannot edit json_data field.
AI-assisted analysis of SillyTavern/SillyTavern@8172dcd0ee (2026-08-13).
Data as JSON: /api/errors/6894313b119e85c6.
Report an issue: GitHub.