{"record":{"id":"76086e09ce0f1315","repo":"block/buzz","slug":"failed-to-ensure-deployment-community-required-wh","errorCode":null,"errorMessage":"Failed to ensure deployment community (required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true): {e}","messagePattern":"Failed to ensure deployment community \\(required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true\\): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/buzz-relay/src/main.rs","lineNumber":373,"sourceCode":"                    \"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_for_bootstrap(&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}\");\n                        return Err(anyhow::anyhow!(\n                            \"Failed to ensure deployment community (required when BUZZ_REQUIRE_RELAY_MEMBERSHIP=true): {e}\"\n                        ));\n                    }\n                    error!(\"Failed to ensure deployment community (non-fatal, membership not required): {e}\");\n                    None\n                }\n            }\n        }\n    };\n\n    // NIP-43: migrate any existing pubkey_allowlist entries to relay_members.\n    // Idempotent — safe to run every startup. Must run before bootstrap_owner\n    // so that existing allowlist users become relay members before the owner\n    // is promoted (otherwise enabling membership locks everyone out).\n    if let Some(community) = deployment_community {\n        match db.backfill_from_allowlist(community).await {\n            Ok(0) => {}\n            Ok(n) => info!(\"Backfilled {n} pubkey_allowlist entries into relay_members\"),","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/block/buzz/blob/ef2aa1ae38fadcc0bc22b8bf6ed96b35933146be/crates/buzz-relay/src/main.rs#L355-L391","documentation":"Fatal startup error: db.ensure_configured_community(&host) — the idempotent call that creates-or-fetches the deployment's own community — failed while BUZZ_REQUIRE_RELAY_MEMBERSHIP=true. The community row is the anchor for all membership writes, so the relay refuses to start; without enforcement the same failure is only logged.","triggerScenarios":"Any DB-level failure during the ensure-community upsert: transient connection drop right after the initial pool connect, permission denied on the communities table for the relay DB user, or a constraint/catalog problem (e.g. migrations not fully applied).","commonSituations":"Postgres restarting at the same moment as the relay; a least-privilege DB role missing INSERT/UPDATE on the community tables; pointing the relay at a database that was created without running migrations.","solutions":["Read the {e} detail — it distinguishes connectivity (retry) from permissions/schema (fix)","Confirm migrations are applied and the DB role can INSERT/UPDATE the community tables","If transient, restart the relay once Postgres is stably healthy","Add a startup ordering gate (depends_on healthcheck / readiness init container) between Postgres and the relay"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Boot gate: require Postgres healthy before the relay starts\n# (same psql 'select 1' loop as error 43).","typeGuard":null,"tryCatchPattern":"// Supervisor: retry relay startup with backoff while the error string starts\n// with \"Failed to ensure deployment community\" and Postgres logs show a\n// transient failure; halt for permission/schema errors.","preventionTips":["Run healthcheck-gated startup ordering between Postgres and the relay","Grant the relay DB role INSERT/UPDATE on the community tables up front","The call is idempotent — safe to simply restart the relay after fixing the cause"],"tags":["postgres","community","nip-43","startup","buzz-relay"],"backgroundTag":"database-write-failed","analyzedSha":"ef2aa1ae38fadcc0bc22b8bf6ed96b35933146be","analyzedAt":"2026-08-20T04:38:24.874Z","contentChangedAt":"2026-08-20T04:38:24.874Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}