Skip to content

Zone template mapping uses positional index instead of zone name matching #136

@5PK

Description

@5PK

Description

translate-zone-names.ts maps source page zones to target template sections by array position rather than by name, which can silently place modules in the wrong zones when the source and target templates define their sections in a different order.

Location

src/lib/pushers/page-pusher/translate-zone-names.ts, lines 16–19

Affected Code

for (let i = 0; i < sourceZoneEntries.length && i < sectionNames.length; i++) {
    const [sourceZoneName, zoneContent] = sourceZoneEntries[i];
    const targetZoneName = sectionNames[i]; // matched purely by position
    translatedZones[targetZoneName] = zoneContent;
}

sectionNames is built by sorting contentSectionDefinitions by itemOrder — but Object.entries(sourceZones) returns source zones in whatever order the page object has them, which is not guaranteed to match the target template's section order.

Scenario That Breaks It

  • Source template sections: [Main, Sidebar] (itemOrder 1, 2)
  • Target template sections: [Sidebar, Main] (itemOrder 1, 2)
  • Result: all Main modules pushed into Sidebar, and vice versa — silently, with no error

Expected Behaviour

Zones should be matched by name (sourceZoneName === targetZoneName) where a match exists, with positional fallback only when names don't match (i.e. when the template itself has been renamed between instances).

Impact

Content is not corrupted in the mapping files, but modules land in the wrong zones on the pushed page. No error is raised.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions