Skip to content

fix: preserve credential on document store loader update#6552

Open
putramkti wants to merge 1 commit into
FlowiseAI:mainfrom
putramkti:bugfix/document-store-credential-update
Open

fix: preserve credential on document store loader update#6552
putramkti wants to merge 1 commit into
FlowiseAI:mainfrom
putramkti:bugfix/document-store-credential-update

Conversation

@putramkti

Copy link
Copy Markdown

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.credential with the existing value when the incoming payload does not already contain a credential:

- if (found.credential) {
+ if (!data.credential && found.credential) {
      data.credential = found.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

  • Verified that updating a document store loader without changing the credential preserves the existing credential value.
  • Verified that explicitly setting a new credential in the update form correctly replaces the old one.

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

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

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.

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) {

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

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.

Suggested change
if (!data.credential && found.credential) {
if (data.credential == null && found.credential) {
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

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.

1 participant