danny-avila/LibreChat · error
An error occurred during file deletion.
Error message
An error occurred during file deletion.
What it means
Thrown by deleteVectors when the RAG API's DELETE /documents endpoint returns a non-404 error status (any status outside 2xx that is not 404). A 404 is treated as success (file already gone), but other error statuses indicate a real failure. The thrown error wraps the axios error message or falls back to a generic message if the error has no message property. This prevents file DB records from being deleted when vector deletion fails, maintaining referential integrity.
Source
Thrown at api/server/services/Files/VectorDB/crud.js:46
headers: {
Authorization: `Bearer ${jwtToken}`,
'Content-Type': 'application/json',
accept: 'application/json',
},
data: [file.file_id],
});
} catch (error) {
logAxiosError({
error,
message: 'Error deleting vectors',
});
if (
error.response &&
error.response.status !== 404 &&
(error.response.status < 200 || error.response.status >= 300)
) {
logger.warn('Error deleting vectors, file will not be deleted');
throw new Error(error.message || 'An error occurred during file deletion.');
}
}
};
/**
* Uploads a file to the configured Vector database
*
* @param {Object} params - The params object.
* @param {Object} params.req - The request object from Express. It should have a `user` property with an `id` representing the user
* @param {Express.Multer.File} params.file - The file object, which is part of the request. The file object should
* have a `path` property that points to the location of the uploaded file.
* @param {string} params.file_id - The file ID.
* @param {string} [params.entity_id] - The entity ID for shared resources.
* @param {Object} [params.storageMetadata] - Storage metadata for dual storage pattern.
*
* @returns {Promise<{ filepath: string, bytes: number }>}
* A promise that resolves to an object containing:
* - filepath: The path where the file is saved.View on GitHub (pinned to 5ff282f900)
Solutions
- Check the RAG API service health and logs for the specific error that occurred.
- Verify RAG_API_URL is correct and the service is reachable from the app server.
- Ensure the JWT signing key used by generateShortLivedToken matches what the RAG API expects.
- Implement a retry with exponential backoff for transient 5xx errors, or queue the deletion for later processing.
- If the RAG API is permanently unavailable, consider manually cleaning up vector records on the RAG side and then proceeding with file deletion.
Defensive patterns
Strategy: retry
Try / catch
try {
await deleteVectors(req, file);
} catch (error) {
if (error.message.includes('file deletion')) {
// RAG API error — queue for retry
logger.warn(`Vector deletion failed for ${file.file_id}, will retry`);
await queueVectorDeletionRetry(file.file_id);
return;
}
throw error;
} Prevention
- Monitor RAG API health and alert on elevated error rates.
- Ensure the JWT signing key matches between the app and RAG API.
- Implement a dead-letter queue for failed vector deletions to retry later.
- Verify RAG_API_URL is reachable from the app server's network.
When it happens
Trigger: Calling deleteVectors(req, file) where the RAG API at RAG_API_URL/documents responds with an HTTP status that is not 2xx and not 404 (e.g., 500, 403, 502). The error.response branch fires, logging a warning and throwing.
Common situations: The RAG API service is down or returning 500-level errors. Or the JWT token generated by generateShortLivedToken is expired or invalid, causing a 401/403. Or the RAG API has a bug or resource exhaustion (e.g., database timeout) causing intermittent 500s. Or network connectivity between the app server and RAG API is degraded.
Related errors
- An error occurred during file upload.
- File embedding failed.
- OpenAI returned `false` for deleted status
- RAG_API_URL not defined
- File embedding failed. The filetype ${file.mimetype} is not
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/012bce1b97f98ce9.
Report an issue: GitHub.