block/buzz · error · anyhow::Error

cannot derive community host; pass --host or set RELAY_URL

Error message

cannot derive community host; pass --host or set RELAY_URL

What it means

resolve_submit_host() needs a community host to scope a deletion request. It first checks --host; when that is absent it falls back to deriving the host from RELAY_URL via buzz_core::tenant::relay_url_authority. This error means NEITHER was usable: --host was not passed and RELAY_URL is unset, empty, or only whitespace after trimming. Deletion is scoped per community, so the tool refuses to guess.

Source

Thrown at crates/buzz-deletion/src/lib.rs:516

            anyhow::bail!("database-only command reached full-service dispatcher")
        }
    }
}

fn resolve_submit_host(host: Option<&str>, relay_url: Option<&str>) -> Result<String> {
    if let Some(host) = host {
        let host = host.trim();
        if host.is_empty() {
            anyhow::bail!("--host must not be empty");
        }
        return Ok(host.to_owned());
    }

    let relay_url = relay_url
        .map(str::trim)
        .filter(|value| !value.is_empty())
        .ok_or_else(|| {
            anyhow::anyhow!("cannot derive community host; pass --host or set RELAY_URL")
        })?;
    let host = buzz_core::tenant::relay_url_authority(relay_url);
    if host.is_empty() {
        anyhow::bail!(
            "cannot derive community host from RELAY_URL; pass --host or set a valid RELAY_URL"
        );
    }
    Ok(host)
}

async fn connect_store() -> Result<DeletionStore> {
    let database_url = required_env("DATABASE_URL")?;
    let db = Db::new(&DbConfig {
        database_url,
        max_connections: env_parse("BUZZ_DB_POOL_SIZE", 20),
        ..DbConfig::default()
    })
    .await?;

View on GitHub (pinned to f956e6fe06)

Solutions

  1. Set RELAY_URL to the relay's URL (e.g. ws://localhost:3000 or wss://relay.example.com) in the environment and re-run — the host (plus non-default port) is derived the same way the relay seeds it.
  2. Or pass the community authority directly: `--host localhost:3000` / `--host relay.example.com`.
  3. For service units, add RELAY_URL (or bake --host into ExecStart) so it doesn't depend on an interactive shell's exports.
  4. Check for empty-but-set values: `echo "[$RELAY_URL]"` — whitespace-only counts as missing here.

Example fix

# before
buzz-deletion submit --requester npub1... --reason "gdpr"
# error: cannot derive community host; pass --host or set RELAY_URL

# after
RELAY_URL=ws://localhost:3000 buzz-deletion submit --requester npub1... --reason "gdpr"
# or: buzz-deletion submit --host localhost:3000 --requester npub1... --reason "gdpr"
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
# deletion commands need a scoping host one way or another
if [ -z "${RELAY_URL// /}" ] && [ -z "${HOST_ARG:-}" ]; then
  echo "set RELAY_URL (ws://host:port) or pass --host" >&2; exit 1
fi

Prevention

When it happens

Trigger: Running `buzz-deletion submit …` (or any command routed through resolve_submit_host) in a shell where RELAY_URL was never exported and no --host flag was given; a systemd/cron unit that only sets DATABASE_URL/S3 vars; whitespace-only RELAY_URL=" " from a template.

Common situations: Deletion executor deployed without copying the relay's full env set; scripts written against dev (where a global export existed) run in CI where it doesn't; .env sourced from the wrong directory.

Related errors


AI-assisted analysis of block/buzz@f956e6fe06 (2026-08-16). Data as JSON: /api/errors/7bf2568e6fdb1fe9. Report an issue: GitHub.