{"record":{"id":"debe0eaa114451f9","repo":"zed-industries/zed","slug":"badpublicnesting","errorCode":"BadPublicNesting","errorMessage":"BadPublicNesting","messagePattern":"BadPublicNesting","errorType":"error_code","errorClass":"RpcError","httpStatus":null,"severity":"error","filePath":"crates/collab/src/db/queries/channels.rs","lineNumber":936,"sourceCode":"            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?;\n\n            let descendent_ids =\n                ChannelId::find_by_statement::<QueryIds>(Statement::from_sql_and_values(\n                    self.pool.get_database_backend(),\n                    \"\n                    UPDATE channels SET parent_path = REPLACE(parent_path, $1, $2)","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/collab/src/db/queries/channels.rs#L918-L954","documentation":"move_channel rejects moves where a public channel would be placed under a non-public parent; BadPublicNesting is the ErrorCode for that visibility mismatch, preserving the invariant that public channels only nest under public ancestors.","triggerScenarios":"Thrown at crates/collab/src/db/queries/channels.rs:936 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the new parent channel public before moving a public channel beneath it","Or make the channel private before the move"],"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"}