fix: preserve credential on document store loader update#6552
Conversation
When updating a document store loader's settings (e.g. changing the confluence credential), the new credential sent in the request body was unconditionally overwritten by the stored credential from the database. This caused credential updates to silently fail — the loader continued using the old credential, resulting in 403 errors on refresh. Fix: only fall back to the stored credential when the request does not provide one. Closes FlowiseAI#6550
There was a problem hiding this comment.
Code Review
This pull request updates the document store service to only assign a found credential to the data object if the credential is not already present. The feedback suggests using a loose nullish check (== null) instead of a logical NOT operator (!) to prevent other falsy values, such as empty strings, from being incorrectly treated as nullish.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (!data.splitterName) data.splitterName = found.splitterName | ||
| if (!data.splitterConfig) data.splitterConfig = found.splitterConfig | ||
| if (found.credential) { | ||
| if (!data.credential && found.credential) { |
There was a problem hiding this comment.
According to the repository's general rules, loose equality (== null) should be used as a standard idiom for a 'nullish' check that covers both null and undefined. Using !data.credential might also incorrectly treat other falsy values (like an empty string "") as nullish, which could prevent users from explicitly clearing a credential if that is represented by an empty string.
| if (!data.credential && found.credential) { | |
| if (data.credential == null && found.credential) { |
References
- In JavaScript/TypeScript, use loose equality (
== null) as a standard idiom for a 'nullish' check that covers bothnullandundefined.
Problem
When updating a document store loader that already has a credential saved, submitting the update form with no credential selected overwrites the existing credential with
undefined. This causes the loader to lose its authentication on every settings update unless the user re-selects the credential each time.Fix
Add a guard to only overwrite
data.credentialwith the existing value when the incoming payload does not already contain a credential:This preserves any credential the user explicitly set in the update while still falling back to the stored value when none is provided.
Scope
packages/server/src/services/documentstore/index.ts(modified, +1/-1)Testing