Skip to content

fix: file loader not picking up uploaded files from API upsert request#6173

Closed
BOOPATB wants to merge 3 commits intoFlowiseAI:mainfrom
BOOPATB:fix/file-loader-api-upsert-3.1
Closed

fix: file loader not picking up uploaded files from API upsert request#6173
BOOPATB wants to merge 3 commits intoFlowiseAI:mainfrom
BOOPATB:fix/file-loader-api-upsert-3.1

Conversation

@BOOPATB
Copy link
Copy Markdown

@BOOPATB BOOPATB commented Apr 8, 2026

Problem

Fixes #6102

When uploading a file via the /api/v1/vector/upsert/:id API endpoint using
multipart/form-data, the file is silently ignored and nothing gets indexed.
This regression was introduced in 3.1.x.

Root Cause

In packages/server/src/utils/upsertVector.ts, the logic that determines
which input field to use for the uploaded file had a copy-paste bug:

// Before (buggy)
} else if (fileInputFieldFromMimeType !== 'txtFile') {
    fileInputField = fileInputFieldFromExt  // ← wrong variable
}

// After (fixed)
} else if (fileInputFieldFromMimeType !== 'txtFile') {
    fileInputField = fileInputFieldFromMimeType  // ← correct variable
}

When a file's extension maps to txtFile but its MIME type correctly
identifies the file type, the code was incorrectly using fileInputFieldFromExt
(which is txtFile) instead of fileInputFieldFromMimeType. This caused the
file to be stored under the wrong input field key, so the File Loader node
never received it.

Changes

  • packages/server/src/utils/upsertVector.ts: one-line fix, use
    fileInputFieldFromMimeType instead of fileInputFieldFromExt in the else-if branch

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 fixes a copy-paste error in upsertVector.ts where the incorrect variable was assigned to fileInputField. The review feedback suggests further improving this logic by adding truthiness checks to prevent assigning falsy values, ensuring a more robust fallback to the default field name.

Comment on lines 96 to 100
if (fileInputFieldFromExt !== 'txtFile') {
fileInputField = fileInputFieldFromExt
} else if (fileInputFieldFromMimeType !== 'txtFile') {
fileInputField = fileInputFieldFromExt
fileInputField = fileInputFieldFromMimeType
}
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

While this change correctly fixes the copy-paste error, the logic should also ensure that fileInputField is not assigned a falsy value (such as undefined or null) if the mapping functions fail to return a valid string. Adding a truthiness check provides a more robust fallback mechanism to the default 'txtFile', preventing potential issues with incorrect field mapping in overrideConfig. This implementation uses an if/else if chain, which is preferred for a small number of conditional branches to maintain readability.

Suggested change
if (fileInputFieldFromExt !== 'txtFile') {
fileInputField = fileInputFieldFromExt
} else if (fileInputFieldFromMimeType !== 'txtFile') {
fileInputField = fileInputFieldFromExt
fileInputField = fileInputFieldFromMimeType
}
if (fileInputFieldFromExt && fileInputFieldFromExt !== 'txtFile') {
fileInputField = fileInputFieldFromExt
} else if (fileInputFieldFromMimeType && fileInputFieldFromMimeType !== 'txtFile') {
fileInputField = fileInputFieldFromMimeType
}
References
  1. Use a default (fallback) implementation unless the specific implementation has meaningfully different behavior or provides better error messages.
  2. For a small number of conditional branches, an if/else if chain may be preferred over a map lookup to maintain readability.

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

2 participants