apostrophecms / apostrophecms/apostrophe
Page being a child of itself
- Dominant language
- JavaScript
- Stars
- 4.6k
- Forks
- 650
- Avg merge
- 19h 21m
- Merged PRs (30d)
- 23
Description
This happened to us in our live environment. A page somehow became a child of itself.
## To Reproduce
In reality **this happened through use of the UI only**, we just don't know how. However, I know how to manipulate the database to replicate the issue.
1. Choose a page to manipulate. I'd recommend using one with type `default-page`.
2. Change the page's `path` property. A normal path might look like this: `"{home-page-id}/{page-id}"`,
change this to `"{home-page-id}/{page-id}/{page-id}"`
## Expected behavior
I don't really know, I guess the expected behaviour would be for this not to happen in the first place.
## Describe the bug
After following the steps above, the page is now a child of itself.
This comes with some side effects:
- The page does not show up in the page tree.
- The page can not be saved, as it has a draft parent (itself), which has a draft parent (itself again), etc.
## Details
**Server Operating System:**
`Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-112-generic x86_64)` with `node:lts-alpine3.15` Docker image
**Screenshots:**
The message that pops up when trying to save this page:

Contributor guide
Research direction
Start by reproducing the database path change described in the issue and inspect the page hierarchy and save flow involved when a page becomes its own parent. Done should include preventing this invalid relationship through the UI or data handling and restoring a page that is already self-parented, with the page tree and save operation working normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, content
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100