Skip to content

fix: restore file upload override when 'file' param is enabled (fixes #6102)#6149

Open
octo-patch wants to merge 2 commits intoFlowiseAI:mainfrom
octo-patch:fix/issue-6102-file-upload-override
Open

fix: restore file upload override when 'file' param is enabled (fixes #6102)#6149
octo-patch wants to merge 2 commits intoFlowiseAI:mainfrom
octo-patch:fix/issue-6102-file-upload-override

Conversation

@octo-patch
Copy link
Copy Markdown

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 the isParameterEnabled check. However, this broke legitimate API file uploads because:

  1. Users configure file overrides by enabling the 'file' parameter in the Flowise UI for their File Loader node.
  2. When files are uploaded via multipart form data, the server maps them to type-specific keys: 'txtFile', 'pdfFile', 'csvFile', etc.
  3. replaceInputsWithConfig then checks isParameterEnabled(nodeLabel, 'txtFile') — but 'txtFile' is never in nodeOverrides; only 'file' is.
  4. Since the check fails, the file path is never applied to the node, and nothing gets indexed.

Additional bug: Both upsertVector.ts and buildChatflow.ts had a copy-paste error in the MIME-type fallback branch — fileInputFieldFromExt was used instead of fileInputFieldFromMimeType when the else-if condition was triggered.

Solution

In replaceInputsWithConfig, when a FILE-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.ts and buildChatflow.ts.

Testing

  1. Create a chatflow/ingestion flow with a File Loader node
  2. In the override config, enable the File input for override
  3. Upload a file via the upsert API using multipart form data:
    POST /api/v1/vector/upsert/{chatflowId}
    Content-Type: multipart/form-data
    files: <your file>
    
  4. Verify the file is indexed in the vector store (was broken before this fix)

…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.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +1194 to 1201
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
}
}
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File Loader Not Picking Up Provided File(s) from Request - After Upgrading from 3.0.4 to 3.1.1

1 participant