zed-industries/zed · error · RpcError

WrongMoveTarget

WrongMoveTarget

Error message

WrongMoveTarget

What it means

move_channel validates that the new parent channel belongs to the same root channel as the channel being moved; WrongMoveTarget is the ErrorCode returned when the roots differ, meaning the move would relocate a channel into a different channel tree.

Solutions

  1. Choose a new parent within the same root channel hierarchy
  2. Move the channel out of its tree via a different mechanism if cross-root moves are intended
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/collab/src/db/queries/channels.rs:923 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/7ce2bbe84b6401b5. Report an issue: GitHub.

Appendix: source

Thrown at crates/collab/src/db/queries/channels.rs:923

        Ok(room_id)
    }

    /// Move a channel from one parent to another
    pub async fn move_channel(
        &self,
        channel_id: ChannelId,
        new_parent_id: ChannelId,
        admin_id: UserId,
    ) -> Result<(ChannelId, Vec<Channel>)> {
        self.transaction(|tx| async move {
            let channel = self.get_channel_internal(channel_id, &tx).await?;
            self.check_user_is_channel_admin(&channel, admin_id, &tx)
                .await?;
            let new_parent = self.get_channel_internal(new_parent_id, &tx).await?;

            if new_parent.root_id() != channel.root_id() {
                Err(anyhow!(ErrorCode::WrongMoveTarget))?;
            }

            if new_parent
                .ancestors_including_self()
                .any(|id| id == channel.id)
            {
                Err(anyhow!(ErrorCode::CircularNesting))?;
            }

            if channel.visibility == ChannelVisibility::Public
                && new_parent.visibility != ChannelVisibility::Public
            {
                Err(anyhow!(ErrorCode::BadPublicNesting))?;
            }

            let root_id = channel.root_id();
            let new_parent_path = new_parent.path();
            let old_path = format!("{}{}/", channel.parent_path, channel.id);

View on GitHub (pinned to f4178619ac)