zed-industries/zed · error

cannot add yourself as a contact

Error message

cannot add yourself as a contact

What it means

Validation guard in the request_contact RPC handler: it fires when the requester and responder user IDs are equal, meaning a user tried to send a contact request to themselves. The handler rejects this before any database write.

Solutions

  1. Target a different user as the contact request responder
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/collab/src/rpc.rs:2768 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/397aece0f53dd3cb. Report an issue: GitHub.

Appendix: source

Thrown at crates/collab/src/rpc.rs:2795

            username: user.username,
            avatar_url: user.avatar_url,
            github_login: user.github_login,
            name: user.name,
        })
        .collect();
    response.send(proto::UsersResponse { users })?;
    Ok(())
}

/// Send a contact request to another user.
async fn request_contact(
    request: proto::RequestContact,
    response: Response<proto::RequestContact>,
    session: MessageContext,
) -> Result<()> {
    let requester_id = session.user_id();
    let responder_id = UserId::from_proto(request.responder_id);
    if requester_id == responder_id {
        return Err(anyhow!("cannot add yourself as a contact"))?;
    }

    let notifications = session
        .db()
        .await
        .send_contact_request(requester_id, responder_id)
        .await?;

    // Update outgoing contact requests of requester
    let mut update = proto::UpdateContacts::default();
    update.outgoing_requests.push(responder_id.to_proto());
    for connection_id in session
        .connection_pool()
        .await
        .user_connection_ids(requester_id)
    {
        session.peer.send(connection_id, update.clone())?;

View on GitHub (pinned to 9d272b0363)