Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions api/src/services/aem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1363,8 +1363,11 @@ const createEntry = async ({
const entryMapping: Record<string, string[]> = {};
const usedEntryUids = new Set<string>();

// Process each entry file
for await (const fileName of read(entriesDir)) {
// Process each entry file. Sorted (not raw fs-readdir-recursive order) so that when two
// files legitimately collide on the same modelId+locale (see CMG-1112), which one "wins"
// and gets migrated is deterministic and reproducible across machines/runs, rather than
// depending on filesystem directory order.
for await (const fileName of [...read(entriesDir)].sort()) {
Comment thread
shradha-nahar marked this conversation as resolved.
const filePath = path.join(entriesDir, fileName);
if (filePath?.startsWith?.(damPath)) {
continue;
Expand All @@ -1373,23 +1376,6 @@ const createEntry = async ({
if (typeof content === 'string') {
const parseData = JSON.parse(content);

// AEM can export a page TEMPLATE's own structure/schema definition (e.g.
// /conf/.../settings/wcm/templates/<template>/structure[.html]) as a separate file
// alongside real pages that use that template β€” it isn't content, just the
// template's own component-allow-list. Exclude it outright rather than letting it
// compete with a real page for the same derived id (see CMG-1112): this removes the
// ambiguity entirely instead of leaving the outcome dependent on directory-walk order.
const repoPath: string | undefined = parseData?.dataLayer?.[parseData?.id]?.['repo:path'];
if (repoPath && /\/settings\/wcm\/templates\/[^/]+\/structure(\.html)?$/.test(repoPath)) {
await customLogger(
projectId,
destinationStackId,
'warn',
getLogMessage(srcFunc, `Skipped entry from "${fileName}": AEM template structure/schema definition, not real content (repo:path "${repoPath}").`, {})
);
continue;
}

// Use the page model's stable "id" as the entry uid so uid-mapper keys
// stay consistent across delta iterations; random uuid only as fallback.
let modelId = typeof parseData?.id === 'string' && parseData.id.trim() !== ''
Expand Down Expand Up @@ -1430,9 +1416,6 @@ const createEntry = async ({
continue;
}
const uid = modelId || uuidv4?.()?.replace?.(/-/g, '');
if (collisionKey) {
usedEntryUids.add(collisionKey);
}
const title = getTitle(parseData);
const isEFragment = isExperienceFragment(parseData);
const templateUid = isEFragment?.isXF ? parseData?.title : parseData?.templateName ?? parseData?.templateType;
Expand All @@ -1446,6 +1429,14 @@ const createEntry = async ({
data.publish_details = [];

if (contentType?.contentstackUid && data && mappedLocale) {
// Reserve the collision key only now that an entry is actually being emitted β€” a
// file that reaches the "no content type matched" / "no mapped locale" branch below
// must NOT consume the key, or it would permanently block a sibling file (sharing
// the same modelId::locale) that could otherwise have produced the real entry,
// leaving zero entries instead of one.
if (collisionKey) {
usedEntryUids.add(collisionKey);
}
const mappedValue = (keyMapper as Record<string, string> | undefined)?.[contentType.contentstackUid];
const resolvedCtUid: string =
mappedValue && mappedValue !== ''
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"overrides": {
"axios": ">=1.16.0",
"nth-check": ">=2.0.1",
"postcss": ">=8.5.10",
"postcss": ">=8.5.23",
"serialize-javascript": ">=6.0.2",
"@babel/runtime": ">=7.26.10",
"lodash": "^4.18.1",
Expand Down
33 changes: 17 additions & 16 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"react-dom": "^18.2.0",
"react-final-form": "^6.5.9",
"react-redux": "^9.1.2",
"react-router": "^7.15.0",
"react-router-dom": "^7.15.0",
"react-router": "^7.18.2",
"react-router-dom": "^7.18.2",
"react-toastify": "npm:@contentstack/react-toastify@6.1.5",
"redux-persist": "^6.0.0",
"sass": "^1.68.0",
Expand Down Expand Up @@ -71,7 +71,8 @@
"ws": ">=8.21.0",
"esbuild": "^0.28.1",
"fast-uri": ">=4.1.1",
"brace-expansion": ">=5.0.9"
"brace-expansion": ">=5.0.9",
"postcss": ">=8.5.23"
},
"eslintConfig": {
"extends": [
Expand Down
Loading