Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/server/src/enterprise/controllers/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const getAllPermissions = async (req: Request, res: Response, next: NextFunction
const allPermissions = appServer.identityManager.getPermissions().toJSON()
const user = req.user as LoggedInUser

if (!user) {
return res.status(StatusCodes.UNAUTHORIZED).json({ message: 'Unauthorized' })
}

let permissions: { [key: string]: { key: string; value: string }[] } = allPermissions

// Mapping of feature flags to permission prefixes
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/utils/buildChatflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export const executeFlow = async ({
if (fileInputFieldFromExt !== 'txtFile') {
fileInputField = fileInputFieldFromExt
} else if (fileInputFieldFromMimeType !== 'txtFile') {
fileInputField = fileInputFieldFromExt
fileInputField = fileInputFieldFromMimeType
}

if (overrideConfig[fileInputField]) {
Expand Down
12 changes: 10 additions & 2 deletions packages/server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,17 @@ export const replaceInputsWithConfig = (
continue
}
} else {
// For FILE-STORAGE:: values (uploaded files mapped to txtFile, pdfFile, etc.),
// also allow override if the generic 'file' parameter is enabled for the node.
// This handles the case where users enable the 'file' input for override in the UI,
// which should also permit the server-side file-type fields to be applied.
const isFileStorageValue =
typeof overrideConfig[config] === 'string' && overrideConfig[config].includes('FILE-STORAGE::')
if (!isParameterEnabled(flowNodeData.label, config)) {
// Only proceed if the parameter is enabled
continue
if (!(isFileStorageValue && isParameterEnabled(flowNodeData.label, 'file'))) {
// Only proceed if the parameter is enabled
continue
}
}
Comment on lines +1194 to 1201
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check for FILE-STORAGE:: values should be more precise to avoid potential false positives and can be optimized by moving it inside the parameter enablement check. Using startsWith instead of includes ensures that we only match actual file storage references, which is consistent with how these values are handled elsewhere in the codebase. Additionally, using an early return with continue is preferred for readability over nested logic.

Suggested change
const isFileStorageValue =
typeof overrideConfig[config] === 'string' && overrideConfig[config].includes('FILE-STORAGE::')
if (!isParameterEnabled(flowNodeData.label, config)) {
// Only proceed if the parameter is enabled
continue
if (!(isFileStorageValue && isParameterEnabled(flowNodeData.label, 'file'))) {
// Only proceed if the parameter is enabled
continue
}
}
if (!isParameterEnabled(flowNodeData.label, config)) {
const isFileStorageValue =
typeof overrideConfig[config] === 'string' && overrideConfig[config].startsWith('FILE-STORAGE::')
if (!(isFileStorageValue && isParameterEnabled(flowNodeData.label, 'file'))) {
// Only proceed if the parameter is enabled
continue
}
}
References
  1. Multiple early returns for validation can be preferable to a single error-aggregating block if the latter is considered more confusing or less readable.

}

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/utils/upsertVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const executeUpsert = async ({
if (fileInputFieldFromExt !== 'txtFile') {
fileInputField = fileInputFieldFromExt
} else if (fileInputFieldFromMimeType !== 'txtFile') {
fileInputField = fileInputFieldFromExt
fileInputField = fileInputFieldFromMimeType
}

if (overrideConfig[fileInputField]) {
Expand Down