{"record":{"id":"cc72b385f54a4938","repo":"block/buzz","slug":"cannot-derive-a-community-host-from-buzz-relay-url","errorCode":null,"errorMessage":"Cannot derive a community host from BUZZ_RELAY_URL ({:?}); a resolvable host is required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true","messagePattern":"Cannot derive a community host from BUZZ_RELAY_URL \\((.+?)\\); a resolvable host is required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/buzz-relay/src/main.rs","lineNumber":269,"sourceCode":"        ));\n    }\n\n    // NIP-43 / multi-tenant: seed the deployment's *own* community before any\n    // membership backfill or owner bootstrap, so those writes are scoped to a\n    // real `(community_id, pubkey)` and not a global pubkey. The host is derived\n    // from `relay_url` with the *same* normalization request resolution uses\n    // (`relay_url_authority` → `normalize_host`), so the bootstrapped owner lands\n    // in exactly the community that live requests for this host will resolve to.\n    //\n    // `ensure_configured_community` is idempotent, so this is safe to run every\n    // startup. An empty authority (unparseable `relay_url`)\n    // is a misconfiguration — fail fast when membership is enforced rather than\n    // seeding an empty-host community that no request can ever resolve to.\n    let deployment_community = {\n        let host = buzz_relay::tenant::relay_url_authority(&config.relay_url);\n        if host.is_empty() {\n            if config.require_relay_membership {\n                return Err(anyhow::anyhow!(\n                    \"Cannot derive a community host from BUZZ_RELAY_URL ({:?}); a resolvable host is required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true\",\n                    config.relay_url\n                ));\n            }\n            error!(\n                relay_url = %config.relay_url,\n                \"Could not derive a community host from relay_url; skipping membership backfill/bootstrap (non-fatal, membership not required)\"\n            );\n            None\n        } else {\n            match db.ensure_configured_community(&host).await {\n                Ok(record) => {\n                    info!(host = %record.host, community = %record.id, \"Deployment community ensured\");\n                    Some(record.id)\n                }\n                Err(e) => {\n                    if config.require_relay_membership {\n                        error!(\"Fatal: failed to ensure deployment community with membership enforcement enabled: {e}\");","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/block/buzz/blob/f956e6fe06a76e50cbd8fba1a162482e752e7f1a/crates/buzz-relay/src/main.rs#L251-L287","documentation":"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.","triggerScenarios":"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.","commonSituations":"Env templating drops the scheme; a placeholder like CHANGEME never replaced; odd quoting when moving between environments; dev setups using bare hostnames.","solutions":["Set BUZZ_RELAY_URL to a full ws:// or wss:// URL (e.g. wss://relay.example.com)","Verify the URL parses: `python3 -c 'import urlparse'`-style check or any URL validator before deploy","Fix the URL even with enforcement off — host-derived community scoping misbehaves without it"],"exampleFix":"# before\nBUZZ_RELAY_URL=relay.example.com\n\n# after\nBUZZ_RELAY_URL=wss://relay.example.com","handlingStrategy":"validation","validationCode":"# The relay URL must carry a scheme so a host can be derived.\n[[ \"${BUZZ_RELAY_URL:-}\" =~ ^wss?://[^/]+ ]] || { echo 'BUZZ_RELAY_URL must be a full ws:// or wss:// URL'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure BUZZ_RELAY_URL with an explicit ws:// or wss:// scheme","Fail CI on placeholder values (CHANGEME, example hosts) in relay env","Remember the host portion determines community scoping — keep it canonical in every environment"],"tags":["config","env-vars","url","startup","multi-tenant"],"backgroundTag":"invalid-url-config","analyzedSha":"f956e6fe06a76e50cbd8fba1a162482e752e7f1a","analyzedAt":"2026-08-16T22:11:40.750Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}