Nodes moved across episode boundaries
Before issue #1352, PATCH /nodes/:id could move a node across an episode
boundary inside one project. The move rewrote path for the node and its
descendants but never episodeNodeId, which every writer and the episode file
list rely on. Three shapes follow:
- Moved out of an episode. The rows still name the old episode. Its file
list drops them, the metadata route reports a wrong
prefix, and writes to the moved folder answer409 node already exists at this path. - Moved into another episode. The same rows, now under a second episode's
path. Neither episode lists them, and new files there answer
409. - Episode moved off its project root, into a folder or another episode.
Uploads to it answer
403 LOST_AUTHORITY, and creating an episode with the same name makes a second one at the project root, which then receives the data.
No rows are lost. Servers with the fix (not yet released) refuse these moves before writing anything. Existing rows stay as they are until someone repairs them; there is no migration.
Find them
Read-only: aggregate and print only. Run it in mongosh against a database
you are authorized to inspect, preferably a secondary, and scope it to one
namespace on a large database. Running it, and any repair, against production
needs explicit approval.
A subtree reports every row, so a moved folder is listed with each of its
descendants. A folder moved from one episode into another appears twice, once
for each episode. An episode nested in another episode is reported as
inside-episode-names-other, together with its own subtree.
names-unavailable-episode is one line per referenced episode, with a row
count. Moves do not cause it: a move never deletes or retypes an episode. It
comes from deleting an episode while rows under it stay live, so it is a
separate finding with no repair here. A soft-deleted state may be expected
where that deletion keeps the subtree on purpose. Raise anything else as its
own issue rather than moving rows to hide it.
Repair
Repair through the normal route, as the project's owner or a WRITE user. Every
move below is one the fixed server still allows, because it brings a node back
to where its episodeNodeId says it belongs. Move only the topmost reported
node of each subtree; its descendants follow.
- Episodes first. For each
episode-off-project-rootrow, move it back:PATCH /nodes/<episode id>with{ "parentId": "<projectNodeId>" }. A409means the by-name upsert already made a second episode with that name. Merging the two is a product decision, not a repair. Rename one with{ "name": "..." }first, then move it. - Rows naming an episode. For a
names-episode-outside-itorinside-episode-names-othersubtree whoseepisodeNodeIdis an episode, move its topmost node into that episode:{ "parentId": "<episodeNodeId>" }, or a folder inside it. - Project-level rows. For an
inside-episode-names-othersubtree whoseepisodeNodeIdisnull, move its topmost node to the project root or a project-level folder.
A 409 on a move means a same-named node already exists there; rename one
first. Run the query again afterwards; it should return nothing for the rows
you repaired.
Do not rewrite path or episodeNodeId directly. If moving back is
unacceptable for a project, that needs a reviewed migration that updates a node
and its whole subtree in one transaction, and a product decision on nested
episodes. Neither exists.