zed-industries/zed · error · anyhow::Error

could not update room participant role

Error message

could not update room participant role

What it means

set_room_participant_role updates the participant's role row; zero rows affected means no participant row matched (room, user), so the role change targeted a user who is not in the room and the transaction reports failure.

Solutions

  1. Confirm the user is currently a participant in the room
  2. Have the user join the room before changing their role
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/collab/src/db/queries/rooms.rs:1164 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/be63a705e54d3c96. Report an issue: GitHub.

Appendix: source

Thrown at crates/collab/src/db/queries/rooms.rs:1164

                self.check_user_has_signed_cla(user_id, room_id, &tx)
                    .await?;
            }

            let result = room_participant::Entity::update_many()
                .filter(
                    Condition::all()
                        .add(room_participant::Column::RoomId.eq(room_id))
                        .add(room_participant::Column::UserId.eq(user_id)),
                )
                .set(room_participant::ActiveModel {
                    role: ActiveValue::set(Some(role)),
                    ..Default::default()
                })
                .exec(&*tx)
                .await?;

            if result.rows_affected != 1 {
                Err(anyhow!("could not update room participant role"))?;
            }
            self.get_room(room_id, &tx).await
        })
        .await
    }

    async fn check_user_has_signed_cla(
        &self,
        user_id: UserId,
        room_id: RoomId,
        tx: &DatabaseTransaction,
    ) -> Result<()> {
        let channel = room::Entity::find_by_id(room_id)
            .one(tx)
            .await?
            .context("could not find room")?
            .find_related(channel::Entity)
            .one(tx)

View on GitHub (pinned to f4178619ac)