Skip to content

fix: custom pages overwrite each other in page sync (all share name "legacy") - #85

Merged
KeinerM merged 4 commits into
raisely:masterfrom
k-r-a-s-s:fix/page-sync-filename-collision
Nov 26, 2026
Merged

KeinerM merged 4 commits into
raisely:masterfrom
k-r-a-s-s:fix/page-sync-filename-collision

Conversation

@k-r-a-s-s

@k-r-a-s-s k-r-a-s-s commented Aug 27, 2026 •

Copy link
Copy Markdown

Problem

raisely update / raisely init write each synced page to pages/<page.name>.json. Template pages have unique names (home, dashboard, profile, …), but every custom page-builder page has name: "legacy" — so on any campaign with more than one custom page, all of them are written to the same legacy.json, last write wins.

Observed on our campaign: the API returns 72 pages, 55 of which are custom (name: "legacy"). After a sync, only the ~20 uniquely-named template pages plus a single legacy.json exist locally — 54 custom pages never land on disk, and legacy.json holds whichever custom page the API happened to return last (which can change between syncs).

Beyond the missing files, this is a correctness hazard: raisely deploy PATCHes every local page JSON by its embedded uuid, so a stale legacy.json snapshot of a semi-random page can silently revert that page's body/status/path in the admin.

Fix

Extract the naming logic into pageFileNames(pages), which computes names for a campaign's page set as a whole:

  • a page's name is used only when it's unique within the campaign (all existing template-page filenames are unchanged: home.json, dashboard.json, …);
  • pages with a shared or missing name are named from their path (/cause-areas → cause-areas.json), matching the existing fallback already used for unnamed pages;
  • residual collisions after character sanitization get a short uuid suffix so no two pages can ever share a file.

Deploy needs no changes — it already resolves the target page from the uuid inside each file, not the filename.

Notes

  • On repos synced with the current behaviour, the first sync after this fix writes custom pages as new path-named files; the old legacy.json is left behind and can be deleted (it duplicates one of the new files' uuid).
  • Added tests/sync.test.js covering unique names, the shared-legacy fallback, unnamed pages, sanitization, and suffix disambiguation. Full suite passes (111/111).

🤖 Generated with Claude Code


Note

Medium Risk
Changes local page file layout and deletes stale JSON on sync, which can surprise existing repos but fixes data-loss and wrong deploy targets; deploy still keys on uuid inside files.

Overview
Fixes page sync so multiple custom page-builder pages (all sharing name: "legacy") no longer clobber a single legacy.json.

Naming is now computed per campaign via pageFileNames(pages): uniquely named template pages still get home.json, profile.json, etc.; shared or missing names use sanitized paths, with UUID suffixes only for residual collisions. Case-insensitive filename clashes are handled so macOS/Windows don't double-write.

syncPages writes each page under the computed name and runs removeStalePageFiles to delete old JSON files when a page's filename changed (e.g. after this fix), without touching unsynced or invalid JSON.

Adds tests/sync.test.js covering naming edge cases, stale cleanup, and an integration-style syncPages scenario.

Reviewed by Cursor Bugbot for commit a78226e. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread src/actions/sync.js Resolved
k-r-a-s-s pushed a commit to k-r-a-s-s/cli that referenced this pull request Aug 27, 2026
Two-pass assignment so a custom page whose path sanitizes to a template
page's name (e.g. /profile vs the profile template at /:id) can never
take that template's filename, regardless of API order. The custom page
gets the uuid-suffixed name instead.

Addresses Bugbot review on raisely#85.

Co-Authored-By: Claude Fable 5 <[email protected]>
@k-r-a-s-s

Copy link
Copy Markdown
Author

Good catch from Bugbot — fixed in 5489e7d. pageFileNames now assigns names in two passes: unique-name (template) filenames are reserved up front, then shared/unnamed pages get path-based names around them, so a custom page at e.g. /profile can never displace profile.json regardless of API order (it gets the uuid-suffixed name instead). Added a regression test for exactly that ordering; suite passes 112/112.

k-r-a-s-s pushed a commit to High-Impact-Athletes/raisely-cli that referenced this pull request Aug 29, 2026
Two-pass assignment so a custom page whose path sanitizes to a template
page's name (e.g. /profile vs the profile template at /:id) can never
take that template's filename, regardless of API order. The custom page
gets the uuid-suffixed name instead.

Addresses Bugbot review on raisely#85.

Co-Authored-By: Claude Fable 5 <[email protected]>
@benrfairless

Copy link
Copy Markdown

@xolott-ark @giovanny-keela Hi there! Are either of you able to approve this PR? It has been outstanding for a while and breaks basic functionality of the cli.

@KeinerM KeinerM left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@k-r-a-s-s Thank you for tracking this down, and sorry this took a while to review. The write-up made the bug easy to reproduce, and the template-name reservation you added after the Bugbot comment works well.

We tested the branch on a staging campaign. Sync now writes every page, and the filenames stay the same between runs. We found one case that affects people who are upgrading.

Sync doesn't remove the file it wrote under the old name, so after the first sync two files share a uuid. In our test:

  • legacy.json and renamed-home-page.json
  • magicLink.json and magic-link-a0a04680.json

raisely local picked the old magicLink.json, and raisely deploy would send both files as updates for the same page, so the old content could win.

Could you have syncPages remove those old files after it writes the new ones? Only files whose uuid was part of this sync and whose filename differs from the new one. Files from pages that weren't in the sync, and files that aren't valid JSON, should stay. A test with an old legacy.json in the pages folder would cover it.

If you'd rather not, we're happy to push this change to your branch or follow up in a separate PR. Thanks again for the fix.

Comment thread src/actions/sync.js Resolved
k-r-a-s-s pushed a commit to High-Impact-Athletes/raisely-cli that referenced this pull request Oct 30, 2026
Two-pass assignment so a custom page whose path sanitizes to a template
page's name (e.g. /profile vs the profile template at /:id) can never
take that template's filename, regardless of API order. The custom page
gets the uuid-suffixed name instead.

Addresses Bugbot review on raisely#85.

Co-Authored-By: Claude Fable 5 <[email protected]>
Kevin Rassool and others added 3 commits November 18, 2026 11:24
syncPages names each local file by page.name, but every custom
(page-builder) page shares the name "legacy". On campaigns with more
than one custom page, all of them are written to the same legacy.json
(last write wins), so most custom pages never appear locally and the
surviving file's identity changes between syncs.

Name files by the page's unique name when it is unique across the
campaign, and fall back to the page path otherwise (cause-areas.json,
terms.json, ...). Residual collisions after sanitization are
disambiguated with a short uuid suffix. Deploy is unaffected: pages are
PATCHed by the uuid stored inside each file.

Co-Authored-By: Claude Fable 5 <[email protected]>
Two-pass assignment so a custom page whose path sanitizes to a template
page's name (e.g. /profile vs the profile template at /:id) can never
take that template's filename, regardless of API order. The custom page
gets the uuid-suffixed name instead.

Addresses Bugbot review on raisely#85.

Co-Authored-By: Claude Fable 5 <[email protected]>
Repos synced before the page naming fix keep the old file (for example
legacy.json) next to the new path-named file, both with the same uuid.
raisely local can pick the stale file, and raisely deploy sends both as
updates for the same page.

After writing pages, delete a page file only when its uuid was part of
this sync and the page was written under a different file name. Files
for pages that weren't synced, and files that aren't valid JSON, stay.
@KeinerM
KeinerM force-pushed the fix/page-sync-filename-collision branch from 5489e7d to fa82592 Compare November 18, 2026 18:44
@KeinerM

KeinerM commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Hi @k-r-a-s-s, thanks again for this fix and for the clear write-up.

We didn't want this to wait any longer, so we pushed the change from my review to your branch (maintainer edits were enabled). Here's what changed:

  • Rebased onto master. The branch now includes the 2.1.1 changes from fix(local): raisely local hangs on every request and drops page overrides #86. Your two commits are unchanged apart from new hashes, so the branch was force-pushed. If you have a local copy, reset it to the remote before making more changes.
  • Removed stale page files after sync. syncPages now deletes a page file only when its uuid was part of the sync and the page was written under a different file name. Files for pages that weren't synced, and files that aren't valid JSON, stay in place. This covers repos synced before this fix, where legacy.json and the new path-named file had the same uuid.
  • Added tests. One test covers removeStalePageFiles on its own, and one runs syncPages end to end against an old legacy.json. The full suite passes (125 tests).

We also tested it with the CLI against a local Raisely stack. With 2.1.1, an old legacy.json stays next to contact.json with the same uuid. With this branch, raisely update removes it and leaves the other files alone.

We'll merge this and ship it in the next patch release, with a note about the renamed page files. Thanks for both fixes. They helped us a lot.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit fa82592. Configure here.

Comment thread src/actions/sync.js Resolved
Comment thread src/actions/sync.js Resolved
On case-insensitive filesystems (macOS, Windows default) magicLink.json
and magiclink.json are the same file, so two pages could still write to
one file, and stale cleanup could delete a file that sync had written.

Compare names case-insensitively when assigning page file names, and
skip cleanup when the old entry is the same file as the one just written.

Addresses Bugbot review on raisely#85.
@KeinerM
KeinerM requested a review from xolott-ark November 18, 2026 19:54
@KeinerM
KeinerM requested review from KeinerM and removed request for KeinerM November 26, 2026 14:36
@KeinerM
KeinerM merged commit 3732c0b into raisely:master Nov 26, 2026
4 checks passed
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