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

channel name can't be blank

Error message

channel name can't be blank

What it means

Thrown by sanitize_channel_name (crates/collab/src/db/queries/channels.rs:339-344), the shared validator used by channel creation and rename. It trims whitespace and strips any leading '#' characters; if nothing remains, the name is blank and the operation is rejected before any DB write.

Source

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

                    true,
                    &tx,
                )
                .await?
                .into_iter()
                .collect();

            Ok(InviteMemberResult {
                channel,
                notifications,
            })
        })
        .await
    }

    fn sanitize_channel_name(name: &str) -> Result<&str> {
        let new_name = name.trim().trim_start_matches('#');
        if new_name.is_empty() {
            Err(anyhow!("channel name can't be blank"))?;
        }
        Ok(new_name)
    }

    /// Renames the specified channel.
    pub async fn rename_channel(
        &self,
        channel_id: ChannelId,
        admin_id: UserId,
        new_name: &str,
    ) -> Result<channel::Model> {
        self.transaction(move |tx| async move {
            let new_name = Self::sanitize_channel_name(new_name)?.to_string();

            let channel = self.get_channel_internal(channel_id, &tx).await?;
            self.check_user_is_channel_admin(&channel, admin_id, &tx)
                .await?;

View on GitHub (pinned to bc538def45)

Solutions

  1. Validate client-side with the same rule before sending the RPC: name.trim().trim_start_matches('#') must be non-empty
  2. Send a name without the leading '#' (the server strips it anyway; sending '#' alone guarantees the error)
  3. If importing channels, filter/repair blank entries in the import data first

Example fix

// before
client.send(CreateChannel { name: "#".into(), .. }).await?;

// after
fn is_valid_channel_name(name: &str) -> bool {
    !name.trim().trim_start_matches('#').is_empty()
}
assert!(is_valid_channel_name(&name));
client.send(CreateChannel { name, .. }).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn sanitize_channel_name(name: &str) -> Option<&str> {
    let trimmed = name.trim().trim_start_matches('#');
    (!trimmed.is_empty()).then_some(trimmed)
}

if let Some(name) = sanitize_channel_name(&input) {
    client.create_channel(name).await?;
}

Prevention

When it happens

Trigger: Calling create_channel or rename_channel with a name of "", " ", "#", "###", or " # " — after trim + trim_start_matches('#') the string is empty. Only leading '#' is stripped, so "a#b" is fine but "###" is blank.

Common situations: Client UIs that don't validate before submitting; users entering only the channel prefix '#'; automated scripts importing channel lists that contain blank or prefix-only rows; mobile clients sending untrimmed input.

Related errors


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