{"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":288,"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(&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":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/block/buzz/blob/f956e6fe06a76e50cbd8fba1a162482e752e7f1a/crates/buzz-relay/src/main.rs#L270-L306","documentation":"ensure_configured_community() idempotently inserts/returns the deployment's community row from the derived host. When that DB call fails with membership enforcement enabled, startup aborts — the subsequent allowlist backfill and owner bootstrap all depend on this community id. Without enforcement the failure is logged and boot continues.","triggerScenarios":"Transient Postgres failure or write rejection during boot; schema drift on the community table after skipped migrations; read-only database.","commonSituations":"Relay pod starts while the DB is restarting or failing over; DB user lacks INSERT on the community table; migrations not yet applied in a new environment.","solutions":["Check Postgres health/logs at the boot timestamp — usually transient; restart the relay","Verify the DB user can SELECT/INSERT on the communities table","Confirm migrations ran (BUZZ_AUTO_MIGRATE or manual) so the table exists"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Connectivity + writable schema check before boot.\npsql \"$DATABASE_URL\" -c 'select 1' >/dev/null || exit 1","typeGuard":null,"tryCatchPattern":"# k8s: let the kubelet retry transient boot-time DB errors\nspec:\n  restartPolicy: Always","preventionTips":["Start the relay only after the database passes readiness","Keep the DB user granted INSERT/SELECT on community tables","Treat repeated failures as non-transient and inspect the DB logs before more restarts"],"tags":["postgres","startup","multi-tenant","community","bootstrap"],"backgroundTag":"database-write-failed","analyzedSha":"f956e6fe06a76e50cbd8fba1a162482e752e7f1a","analyzedAt":"2026-08-16T22:11:40.750Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}