block/buzz · critical · anyhow::Error

Cannot derive a community host from BUZZ_RELAY_URL ({:?}); a

Error message

Cannot derive a community host from BUZZ_RELAY_URL ({:?}); a resolvable host is required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true

What it means

The deployment community is keyed by the host derived from BUZZ_RELAY_URL (relay_url_authority → normalize_host). If that derivation yields an empty host — an unparseable relay_url — and membership enforcement is on, startup fails: seeding an empty-host community that no live request could ever resolve to would be a misconfiguration. Without enforcement it degrades to a logged warning and bootstrap is skipped.

Source

Thrown at crates/buzz-relay/src/main.rs:269

        ));
    }

    // NIP-43 / multi-tenant: seed the deployment's *own* community before any
    // membership backfill or owner bootstrap, so those writes are scoped to a
    // real `(community_id, pubkey)` and not a global pubkey. The host is derived
    // from `relay_url` with the *same* normalization request resolution uses
    // (`relay_url_authority` → `normalize_host`), so the bootstrapped owner lands
    // in exactly the community that live requests for this host will resolve to.
    //
    // `ensure_configured_community` is idempotent, so this is safe to run every
    // startup. An empty authority (unparseable `relay_url`)
    // is a misconfiguration — fail fast when membership is enforced rather than
    // seeding an empty-host community that no request can ever resolve to.
    let deployment_community = {
        let host = buzz_relay::tenant::relay_url_authority(&config.relay_url);
        if host.is_empty() {
            if config.require_relay_membership {
                return Err(anyhow::anyhow!(
                    "Cannot derive a community host from BUZZ_RELAY_URL ({:?}); a resolvable host is required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true",
                    config.relay_url
                ));
            }
            error!(
                relay_url = %config.relay_url,
                "Could not derive a community host from relay_url; skipping membership backfill/bootstrap (non-fatal, membership not required)"
            );
            None
        } else {
            match db.ensure_configured_community(&host).await {
                Ok(record) => {
                    info!(host = %record.host, community = %record.id, "Deployment community ensured");
                    Some(record.id)
                }
                Err(e) => {
                    if config.require_relay_membership {
                        error!("Fatal: failed to ensure deployment community with membership enforcement enabled: {e}");

View on GitHub (pinned to f956e6fe06)

Solutions

  1. Set BUZZ_RELAY_URL to a full ws:// or wss:// URL (e.g. wss://relay.example.com)
  2. Verify the URL parses: `python3 -c 'import urlparse'`-style check or any URL validator before deploy
  3. Fix the URL even with enforcement off — host-derived community scoping misbehaves without it

Example fix

# before
BUZZ_RELAY_URL=relay.example.com

# after
BUZZ_RELAY_URL=wss://relay.example.com
Defensive patterns

Strategy: validation

Validate before calling

# The relay URL must carry a scheme so a host can be derived.
[[ "${BUZZ_RELAY_URL:-}" =~ ^wss?://[^/]+ ]] || { echo 'BUZZ_RELAY_URL must be a full ws:// or wss:// URL'; exit 1; }

Prevention

When it happens

Trigger: BUZZ_RELAY_URL empty, missing its scheme (e.g. `relay.example.com` instead of `wss://relay.example.com`), or otherwise unparseable, while BUZZ_REQUIRE_RELAY_MEMBERSHIP=true.

Common situations: Env templating drops the scheme; a placeholder like CHANGEME never replaced; odd quoting when moving between environments; dev setups using bare hostnames.

Related errors


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