zed-industries/zed · error

could not update room participant location

Error message

could not update room participant location

What it means

Thrown by set_room_participant_location when the UPDATE of location_kind/location_project_id on room_participant affects a row count other than 1. The UPDATE targets the caller's own participant row in the room, so a miss means the server has no participant row (with answering connection) for this connection: the user is not currently joined to the room.

Source

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

                        )
                        .add(
                            room_participant::Column::AnsweringConnectionServerId
                                .eq(connection.owner_id as i32),
                        ),
                )
                .set(room_participant::ActiveModel {
                    location_kind: ActiveValue::set(Some(location_kind)),
                    location_project_id: ActiveValue::set(location_project_id),
                    ..Default::default()
                })
                .exec(&*tx)
                .await?;

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

    /// Sets the role of a participant in the given room.
    pub async fn set_room_participant_role(
        &self,
        admin_id: UserId,
        room_id: RoomId,
        user_id: UserId,
        role: ChannelRole,
    ) -> Result<TransactionGuard<proto::Room>> {
        self.room_transaction(room_id, |tx| async move {
            room_participant::Entity::find()
                .filter(
                    Condition::all()
                        .add(room_participant::Column::RoomId.eq(room_id))

View on GitHub (pinned to bc538def45)

Solutions

  1. Only send location updates for rooms recorded as joined on this connection, and clear that record on leave/kick/room-updated events
  2. On this error, silently drop the update (or attempt a rejoin) rather than surfacing it to the user
  3. Ensure join_room/rejoin_room succeeds before the first presence update for that room

Example fix

// before
client.set_room_participant_location(room_id, location).await?;

// after (track membership, ignore stale updates)
if self.joined_rooms.contains(&room_id) {
    if let Err(err) = client.set_room_participant_location(room_id, location).await {
        if err.to_string().contains("could not update room participant location") {
            self.joined_rooms.remove(&room_id); // membership was lost
        } else {
            return Err(err);
        }
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Send presence only for rooms joined on this connection.
if !self.joined_rooms.contains(&room_id) {
    return Ok(());
}
client.set_room_participant_location(room_id, location).await?;

Try / catch

if let Err(err) = client.set_room_participant_location(room_id, location).await {
    if err.to_string().contains("could not update room participant location") {
        self.joined_rooms.remove(&room_id); // membership lost; skip future updates
        return Ok(());
    }
    return Err(err);
}

Prevention

When it happens

Trigger: Sending a location/presence update for a room the user was kicked from or left; sending it before join_room completed; sending after a reconnect where rejoin failed or was skipped; sending for a room that was deleted.

Common situations: Presence updates queued and flushed after leaving a room; UI still showing a room as active after a kick event was missed; reconnect logic that restores the UI but forgets to rejoin rooms before emitting presence.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/9df9530ed6c0e0e5. Report an issue: GitHub.