{"record":{"id":"c854b6b890ff0e02","repo":"zed-industries/zed","slug":"circularnesting","errorCode":"CircularNesting","errorMessage":"CircularNesting","messagePattern":"CircularNesting","errorType":"error_code","errorClass":"RpcError","httpStatus":null,"severity":"error","filePath":"crates/collab/src/db/queries/channels.rs","lineNumber":930,"sourceCode":"        channel_id: ChannelId,\n        new_parent_id: ChannelId,\n        admin_id: UserId,\n    ) -> Result<(ChannelId, Vec<Channel>)> {\n        self.transaction(|tx| async move {\n            let channel = self.get_channel_internal(channel_id, &tx).await?;\n            self.check_user_is_channel_admin(&channel, admin_id, &tx)\n                .await?;\n            let new_parent = self.get_channel_internal(new_parent_id, &tx).await?;\n\n            if new_parent.root_id() != channel.root_id() {\n                Err(anyhow!(ErrorCode::WrongMoveTarget))?;\n            }\n\n            if new_parent\n                .ancestors_including_self()\n                .any(|id| id == channel.id)\n            {\n                Err(anyhow!(ErrorCode::CircularNesting))?;\n            }\n\n            if channel.visibility == ChannelVisibility::Public\n                && new_parent.visibility != ChannelVisibility::Public\n            {\n                Err(anyhow!(ErrorCode::BadPublicNesting))?;\n            }\n\n            let root_id = channel.root_id();\n            let new_parent_path = new_parent.path();\n            let old_path = format!(\"{}{}/\", channel.parent_path, channel.id);\n            let new_path = format!(\"{}{}/\", new_parent_path, channel.id);\n            let new_order = max_order(&new_parent_path, &tx).await? + 1;\n\n            let mut model = channel.into_active_model();\n            model.parent_path = ActiveValue::Set(new_parent.path());\n            model.channel_order = ActiveValue::Set(new_order);\n            let channel = model.update(&*tx).await?;","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/collab/src/db/queries/channels.rs#L912-L948","documentation":"move_channel checks whether the channel being moved appears in the new parent's ancestor chain; CircularNesting is returned when it does, since moving a channel under its own descendant would create a cycle in the channel tree.","triggerScenarios":"Thrown at crates/collab/src/db/queries/channels.rs:930 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a new parent that is not a descendant of the channel being moved","Restructure the tree in multiple steps to avoid the cycle"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}