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

contact already requested

Error message

contact already requested

What it means

send_contact_request performs a conditional upsert on the contact row; this error fires when the update path matches an existing pending (not yet accepted) request in the opposite direction, meaning a contact request between the two users already exists and a duplicate cannot be created.

Solutions

  1. Accept or dismiss the existing pending contact request instead of sending a new one
  2. Have the other user respond to the outstanding request first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/collab/src/db/queries/contacts.rs:172 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/3aa85ba1bab5f860. Report an issue: GitHub.

Appendix: source

Thrown at crates/collab/src/db/queries/contacts.rs:172

                        (contact::Column::ShouldNotify, false.into()),
                    ])
                    .action_and_where(
                        contact::Column::Accepted.eq(false).and(
                            contact::Column::AToB
                                .eq(a_to_b)
                                .and(contact::Column::UserIdA.eq(id_b))
                                .or(contact::Column::AToB
                                    .ne(a_to_b)
                                    .and(contact::Column::UserIdA.eq(id_a))),
                        ),
                    )
                    .to_owned(),
            )
            .exec_without_returning(&*tx)
            .await?;

            if rows_affected == 0 {
                Err(anyhow!("contact already requested"))?;
            }

            Ok(self
                .create_notification(
                    receiver_id,
                    rpc::Notification::ContactRequest {
                        sender_id: sender_id.to_proto(),
                    },
                    true,
                    &tx,
                )
                .await?
                .into_iter()
                .collect())
        })
        .await
    }

View on GitHub (pinned to f4178619ac)