fix: restore file upload override when 'file' param is enabled (fixes #6102)#6149
fix: restore file upload override when 'file' param is enabled (fixes #6102)#6149octo-patch wants to merge 2 commits intoFlowiseAI:mainfrom
Conversation
…ixes FlowiseAI#6105) When GET /api/v1/auth/resolve is called without authentication, the request is whitelisted (passthrough) and matches the GET /api/v1/auth/:type route with type='resolve'. This calls getAllPermissions() where req.user is undefined, causing a 500 error: 'Cannot read properties of undefined (reading isOrganizationAdmin)'. Add an early guard to return 401 Unauthorized if no user is present, preventing the crash and returning a proper error response.
…lowiseAI#6102) Commit c8282c9 removed the special case that allowed FILE-STORAGE:: values to bypass override permission checks. This broke API file uploads because users enable the 'file' parameter for override in the UI, but the server maps uploaded files to type-specific keys ('txtFile', 'pdfFile', etc.) which were then blocked. Fix: When a FILE-STORAGE:: value is blocked by the specific-param check, also allow it if the generic 'file' parameter is enabled for that node. This restores file upload functionality without reintroducing the original security bypass. Also fix a copy-paste bug in both upsertVector.ts and buildChatflow.ts where the mime-type fallback branch incorrectly used fileInputFieldFromExt instead of fileInputFieldFromMimeType.
There was a problem hiding this comment.
Code Review
This pull request introduces an unauthorized check in the authentication controller and fixes logic errors in file input field assignments within buildChatflow.ts and upsertVector.ts. It also updates the input replacement logic to allow FILE-STORAGE:: overrides when the generic 'file' parameter is enabled. Feedback was provided to improve the precision of the file storage check by using startsWith and to optimize the variable scope.
| 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 | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
| 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
- Multiple early returns for validation can be preferable to a single error-aggregating block if the latter is considered more confusing or less readable.
Fixes #6102
Problem
After the security fix in commit c8282c9 ("Fix Parameter Override Bypass", #5667), file uploads via the upsert API stopped being indexed.
Root cause: The fix removed a special case that allowed
FILE-STORAGE::values to bypass theisParameterEnabledcheck. However, this broke legitimate API file uploads because:'file'parameter in the Flowise UI for their File Loader node.'txtFile','pdfFile','csvFile', etc.replaceInputsWithConfigthen checksisParameterEnabled(nodeLabel, 'txtFile')— but'txtFile'is never innodeOverrides; only'file'is.Additional bug: Both
upsertVector.tsandbuildChatflow.tshad a copy-paste error in the MIME-type fallback branch —fileInputFieldFromExtwas used instead offileInputFieldFromMimeTypewhen the else-if condition was triggered.Solution
In
replaceInputsWithConfig, when aFILE-STORAGE::value is not directly enabled by name, also check if the generic'file'parameter is enabled for that node. This restores file upload functionality while keeping the security constraint that at least one override permission must be configured.The MIME-type copy-paste bug is also fixed in both
upsertVector.tsandbuildChatflow.ts.Testing
Fileinput for override