Skip to content

Fix: deduplicate modules on app export and import#16636

Merged
johnsoncherian merged 2 commits into
chore/bump-version-3.21.43-betafrom
fix/module-import-deduplication
Jun 8, 2026
Merged

Fix: deduplicate modules on app export and import#16636
johnsoncherian merged 2 commits into
chore/bump-version-3.21.43-betafrom
fix/module-import-deduplication

Conversation

@vjaris42

@vjaris42 vjaris42 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

📝 What this does

Fixes a duplicate key constraint violation when importing apps that have multiple ModuleViewer components referencing the same module. The export was serializing N copies of the module (one per ModuleViewer), and the import loop tried to create the same module N times on a fresh DB.

🔀 Changes

  • Added deduplication of module entries by moduleId (co_relation_id) on the export path before calling this.export() for each module
  • Added deduplication of appParams.modules by co_relation_id or name on the import path before the creation loop in mapModulesForAppImport()
  • The 5 ModuleViewer component instances remain intact — only the duplicated module definitions are collapsed

🧪 How to test

  • Reset the database (db:reset)
  • Export an app that uses the same module in multiple ModuleViewer components (e.g., "User BL Checker" used 5 times)
  • Import the exported JSON via file upload
  • Verify the app imports successfully without "app name already exists" error
  • Verify all ModuleViewer instances render correctly in the imported app

QA Checklist

  • Integration Testing.
  • Smoke Testing.
  • Bug Fixes Verification.
  • Cross browser UI check. (Firefox, safari, chrome)
  • Verify features on Dark and Light mode.
  • Test feature on CE, EE, cloud
  • Platform Automation Testing: Action URL, GitSync check - Expected cases are failing
  • Marketplace Automation Testing: Action URL
  • Migration testing.
  • Added tested Label for PR
  • Import/Export/GitSync/Cloning
  • Test System Upgrade/Staging Instance(for cloud) (Sanity + Test System Specific. Cases)
  • Performance Benchmark
  • Cross-Platform Dependency Update

…raint violation

When an app has multiple ModuleViewer components referencing the same
module, the export serializes one copy per component. On import to a
fresh workspace, the loop attempts to create the same module multiple
times, violating the app_name_organization_id_unique constraint.

Export side: deduplicate moduleAppIds by moduleId (co_relation_id)
before calling this.export() for each module.

Import side: deduplicate appParams.modules by co_relation_id or name
before the creation loop in mapModulesForAppImport().
@netlify

netlify Bot commented Jun 1, 2026

Copy link
Copy Markdown

Deploy Preview for storybook-tooljet failed.

Name Link
🔨 Latest commit 65f3fb5
🔍 Latest deploy log https://app.netlify.com/projects/storybook-tooljet/deploys/6a1de924d47cf00008b01d6e

@vjaris42 vjaris42 changed the base branch from lts-3.16 to main June 1, 2026 20:19
@johnsoncherian johnsoncherian changed the base branch from main to chore/bump-version-3.21.43-beta June 8, 2026 19:19
@johnsoncherian johnsoncherian merged commit a86a472 into chore/bump-version-3.21.43-beta Jun 8, 2026
452 of 455 checks passed
@johnsoncherian johnsoncherian deleted the fix/module-import-deduplication branch June 8, 2026 19:19
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.

4 participants