fix: always create content type on test migration, disable Save when …#1120
Conversation
…no mappable entries
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
umesh-more-cstk
left a comment
There was a problem hiding this comment.
Review: fix test-migration content-type creation + Save-button lock
Non-gating COMMENT review. Two independent fixes; both are on the right track and well scoped (touches only api + ui, matching the Affected Areas — no lockfile/cross-package churn). I traced the field-attacher call sites, the entry-mapper pagination flow, and the content-type write path at the head commit.
Verified good
field-attacher.utils.ts— theif (isTest) / else if (iteration === 1) / elserestructuring is correct and mutually exclusive; no double-create. The real (final) migration atmigration.service.ts:885correctly omitsisTest, so it defaults tofalseand the iteration/skip logic is preserved. TheisTest: truewiring atmigration.service.ts:453(test flow) is right._canSelect = !!entry.contentstackEntryUidsemantics are consistent with the checkboxrowSelectCheckboxPropand the Save intent.
Blocking
entryMapper.tsx:698— the new Save-disable predicate inspects only the current page (tableData), which for this step is a single server-paginated slice. It can disable Save when the content type does have mappable entries (they're on another page) or when the user has unsaved selections made on a previous page. Details + fix inline.
Non-blocking
field-attacher.utils.ts:50-51(question) — always-create on test migrations interacts with the append-basedsaveContent(schemaData.push) andclearStaleEntries(scoped toentries/only, socontent_types/schema.jsonis never cleared). Please confirm the test stack / itscontent_typesdir is fresh per run so repeated/delta test migrations don't accumulate duplicate content-type schema entries.field-attacher.utils.ts:53(nit) — theisTestanditeration === 1branches callcontenTypeMakerwith byte-identical args; could collapse to one condition.
Out-of-diff note (PR description)
The description's rationale — "Previously the isTest block and the iteration block both ran on the same pass, causing each content type to be created twice" — doesn't match the diff base: the pre-change code had only if (iteration === 1), no isTest block, so there was no double-create on dev. The actual prior bug this fixes is that delta (iteration 2+) test migrations skipped content-type creation into the fresh test stack. The resulting code is correct; just worth aligning the description so reviewers test the right scenario.
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
🔗 Jira Ticket
. CMG-995
· CMG-1048
📋 PR Type
📝 Description
What changed?
api): Added anisTestflag. On test migrations the content type is now always (re)created into the test stack, short-circuiting the iteration-based skip logic. Previously theisTestblock and the iteration block both ran on the same pass, causing each content type to be created twice.ui): Save button is now disabled when the selected content type has no mappable entry (no row has a Contentstack UID), on top of the existing in-flight-migration lock.Why?
🧩 Affected Areas
api— Node.js backendui— React frontendupload-api— Upload API serverdocker/docker-compose🧪 How to Test
-for Contentstack UID → Save should be disabled.Expected result: Test migrations create content types once; Save is only enabled when there's something mappable to save.
📸 Screenshots / Recordings
🔗 Related PRs / Dependencies
✅ Author Checklist
feature/,bugfix/, orhotfix/+ 5–30 lowercase chars.env/example.envupdated if new environment variables were added — N/Anpm test)README.md/ docs updated if behaviour changed👀 Reviewer Notes
Focus on the branching in
fieldAttacher— the fix converts the old separateif (isTest)+if (iteration === 1)blocks into a singleif / else if / elseso test migrations no longer fall through into the iteration logic.