Skip to content

Fix: plugin DS shows false unsaved state on default branch after git sync#16540

Merged
johnsoncherian merged 8 commits into
mainfrom
fix/plugin-ds-false-unsaved-git-sync
Jun 3, 2026
Merged

Fix: plugin DS shows false unsaved state on default branch after git sync#16540
johnsoncherian merged 8 commits into
mainfrom
fix/plugin-ds-false-unsaved-git-sync

Conversation

@RndmCodeGuy20
Copy link
Copy Markdown
Collaborator

@RndmCodeGuy20 RndmCodeGuy20 commented May 22, 2026

What

Two fixes bundled together — both related to data source consistency in git-sync environments.

1. Plugin DS shows false unsaved state on default branch after git sync (frontend)

When a plugin-type data source is pulled from git, encrypted fields (credentials) are stripped from the git file during serialization — they're never stored in git. After a pull, the DSVO is missing those keys entirely.

The save-state check compared state.options (missing encrypted keys) against normalizedSavedOptions (which fills missing keys from dsDefaults via the plugin manifest), producing a false mismatch on first open — the DS appeared unsaved and triggered a blocking modal.

Fix: normalize state.options with dsDefaults using the same reduction before the deepEqual comparison, so both sides are symmetric and the initial diff is zero.

2. Non-branch DS rename had no uniqueness check + isDefault DSV name was never synced (backend)

Before this PR, renaming a data source on the non-branch path (no git sync / license expired) had no uniqueness enforcement — ensureUniqueActiveNameForUpdate was only called inside the branch path. Additionally, renaming a DS updated data_sources.name but left data_source_versions.name (isDefault DSV) stale, causing drift between the two tables.

Fix: added ensureUniqueActiveNameForUpdate on the non-branch rename path, and sync the isDefault DSV name whenever a DS is renamed outside a branch context.

Why no migrations

Existing duplicate names were already cleaned up by migration 1773229178900 (ships before this PR). By the time ensureUniqueActiveNameForUpdate runs in production, the DB is already clean. No backfill needed — these changes enforce consistency going forward.

Changes

  • frontend/src/modules/dataSources/components/DataSourceManager/DataSourceManager.jsx — normalize options state with dsDefaults before deepEqual comparison
  • server/src/modules/data-sources/util.service.ts — uniqueness check + isDefault DSV name sync on non-branch rename path

…sync

Encrypted fields are omitted from git serialization (credentials are never
stored in git). After a pull, the DSVO is missing those keys. The save-state
check compared state.options (missing encrypted keys) against
normalizedSavedOptions (which fills missing keys from dsDefaults/manifest),
producing a false mismatch on first open for plugin-type datasources.

Fix: normalize state.options with dsDefaults using the same reduction before
the deepEqual comparison, so both sides are symmetric.
@RndmCodeGuy20 RndmCodeGuy20 changed the base branch from develop to main May 22, 2026 08:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@nechalmaggon nechalmaggon added the create-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚀 EE Pre-release Review App Deployed!

Resource Link
App URL https://tooljet-ee-pre-release-pr-16540.onrender.com
Render Dashboard https://dashboard.render.com/web/srv-d89uhukm0tmc739jgse0

Deployed using DockerHub-based pipeline - Pre-release Edition

@github-actions github-actions Bot added active-ee-pre-release-review-app For pre-release (github action build and deploy on render)) and removed create-ee-pre-release-review-app For pre-release (github action build and deploy on render)) labels May 25, 2026
@adishM98 adishM98 added the suspend-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label May 26, 2026
@github-actions github-actions Bot removed the active-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label May 26, 2026
@nechalmaggon nechalmaggon removed the suspend-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label Jun 2, 2026
@github-actions github-actions Bot added the active-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label Jun 2, 2026
… name sync

!isGitEnabled skipped the isDefault DSV name update on the default git branch,
leaving it stale after a rename. shouldUpdateDefault is already true for both
the no-git case and default-branch renames, and false only for feature branches.
… unsaved state for plugin DSes

For new tj:version schema plugins (GitHub, OpenAI, Supabase, Plivo, etc.),
dsDefaults is empty so the prior reduce-based normalization was a no-op.
Encrypted fields stripped from git-synced DSVOs are absent from
normalizedSavedOptions while DynamicForm initializes them as { value: '' }
in state.options, producing a false mismatch on default branch open.

Fill missing encrypted schema fields from dataSourceMeta.options with
{ value: '' } on both sides. Resolve the active key form from
normalizedCurrentOptions first (DynamicForm may camelize schema keys,
e.g. auth_token → authToken) to avoid introducing duplicate snake/camel
keys that cause the opposite mismatch.
branchId presence already implies git is enabled — no need to query
WorkspaceBranch a second time to derive isGitEnabled. Hoist isGitEnabled
into the existing branchId branch (true by definition) and only hit the
DB for the ambiguous !branchId case. Reduces WorkspaceBranch reads from
two to one per update call when branchId is present.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🔄 EE Pre-release Review App Rebuilding

New commit 0c7fd79 pushed. Image updated and deployment triggered.

Using cached layers for faster build

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🔄 EE Pre-release Review App Rebuilding

New commit ea2398d pushed. Image updated and deployment triggered.

Using cached layers for faster build

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🔄 EE Pre-release Review App Rebuilding

New commit f70c058 pushed. Image updated and deployment triggered.

Using cached layers for faster build

@adishM98 adishM98 added the suspend-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label Jun 2, 2026
@github-actions github-actions Bot removed the active-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label Jun 2, 2026
@YuktiGoyal02 YuktiGoyal02 added run-cypress-platform-ee and removed suspend-ee-pre-release-review-app For pre-release (github action build and deploy on render)) labels Jun 3, 2026
@github-actions github-actions Bot added the active-ee-pre-release-review-app For pre-release (github action build and deploy on render)) label Jun 3, 2026
@YuktiGoyal02 YuktiGoyal02 added run-cypress-marketplace-ee run marketplace cypress for ee and removed active-ee-pre-release-review-app For pre-release (github action build and deploy on render)) labels Jun 3, 2026
@johnsoncherian johnsoncherian merged commit 6ec975e into main Jun 3, 2026
340 checks passed
@johnsoncherian johnsoncherian deleted the fix/plugin-ds-false-unsaved-git-sync branch June 3, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants