mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 07:01:07 +03:00
Bugfix/Refactor createFileAttachment to streamline chatId validation (#4740)
Removed redundant chatId validation and path traversal checks, improving code clarity and maintainability. The chatId is now validated after the chatflowid check, ensuring proper error handling for invalid inputs.
This commit is contained in:
@@ -30,17 +30,12 @@ export const createFileAttachment = async (req: Request) => {
|
||||
if (!chatflowid || !isValidUUID(chatflowid)) {
|
||||
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid chatflowId format - must be a valid UUID')
|
||||
}
|
||||
|
||||
const chatId = req.params.chatId
|
||||
if (!chatId || !isValidUUID(chatId)) {
|
||||
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid chatId format - must be a valid UUID')
|
||||
}
|
||||
|
||||
// Check for path traversal attempts
|
||||
if (isPathTraversal(chatflowid) || isPathTraversal(chatId)) {
|
||||
if (isPathTraversal(chatflowid)) {
|
||||
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid path characters detected')
|
||||
}
|
||||
|
||||
const chatId = req.params.chatId
|
||||
|
||||
// Validate chatflow exists and check API key
|
||||
const chatflow = await appServer.AppDataSource.getRepository(ChatFlow).findOneBy({
|
||||
id: chatflowid
|
||||
|
||||
Reference in New Issue
Block a user