{"record":{"id":"dd64ca0428cc88b9","repo":"block/buzz","slug":"load-desired-state-live-roster","errorCode":null,"errorMessage":"load desired-state live roster","messagePattern":"load desired-state live roster","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/buzz-db/src/store/channel_members.rs","lineNumber":3207,"sourceCode":"        let stale = roster(\"member\", base + 1);\n        let error = db\n            .replace_addressable_event(community, &stale, Some(channel))\n            .await\n            .expect_err(\"desired-state fence must reject stale role\");\n        assert!(matches!(\n            error,\n            DbError::Sqlx(sqlx::Error::Database(ref db_error))\n                if db_error.code().as_deref() == Some(\"23514\")\n        ));\n        let live_id: Vec<u8> = sqlx::query_scalar(\n            \"SELECT id FROM events WHERE community_id=$1 AND channel_id=$2 \\\n             AND kind=39002 AND deleted_at IS NULL\",\n        )\n        .bind(community_uuid)\n        .bind(channel)\n        .fetch_one(&pool)\n        .await\n        .expect(\"load desired-state live roster\");\n        assert_eq!(live_id, fresh.id.as_bytes().to_vec());\n\n        drop_scratch_db(&admin, pool, &scratch_name).await;\n    }\n}\n","sourceCodeStart":3189,"sourceCodeEnd":3213,"githubUrl":"https://github.com/block/buzz/blob/dad5a33865fc81a2e55b3b60746632f615ec1e3a/crates/buzz-db/src/store/channel_members.rs#L3189-L3213","documentation":"Panic from a sqlx `fetch_one(...).await.expect(\"load desired-state live roster\")` — the test queries the live kind:39002 row directly from Postgres to verify the desired-state bootstrap wrote the fresh roster event. fetch_one errors if the query returns zero rows or the connection fails, so the expect panics.","triggerScenarios":"The kind=39002 row for the bound community/channel is missing (the earlier replace_addressable_event did not persist), the row was soft-deleted (deleted_at IS NOT NULL), or the Postgres connection dropped.","commonSituations":"Desired-state bootstrap (pgschema apply path) not running the reconcile/seed steps, scratch DB teardown running before the assert, or test ordering leaving stale deleted_at markers on the row.","solutions":["Verify the earlier steps of the test succeeded (fresh.id matches what was published) before this query.","Check that the desired-state bootstrap wrote the roster with deleted_at NULL for this community/channel.","Confirm TEST_DATABASE_URL connectivity and that the query's WHERE clause (community id, channel, kind=39002, deleted_at IS NULL) matches the persisted columns.","If row conflicts arise from re-runs, clean the scratch DB in setup instead of relying on unique timestamps."],"exampleFix":"// before\nlet (live_id,) = sqlx::query_as::<_, (Vec<u8>,)>(q).bind(community_uuid).bind(channel).fetch_one(&pool).await.expect(\"load desired-state live roster\");\n// after\nlet row = sqlx::query_as::<_, (Vec<u8>,)>(q).bind(community_uuid).bind(channel).fetch_optional(&pool).await\n    .expect(\"query live roster\");\nlet (live_id,) = row.unwrap_or_else(|| panic!(\"no live kind:39002 roster for community {community_uuid} channel {channel}\"));","handlingStrategy":"validation","validationCode":"// check the row exists before the strict fetch_one\nlet exists = sqlx::query(\n    \"SELECT EXISTS(SELECT 1 FROM events WHERE community=$1 AND channel=$2 AND kind=39002 AND deleted_at IS NULL)\"\n).bind(community_uuid).bind(channel).fetch_one(&pool).await.expect(\"roster existence probe\");\nassert!(exists.get::<bool, _>(0), \"desired-state bootstrap must persist a live kind:39002 roster\");","typeGuard":null,"tryCatchPattern":"let row = sqlx::query_as::<_, (Vec<u8>,)>(q).bind(community_uuid).bind(channel)\n    .fetch_optional(&pool).await.expect(\"query live roster\");\nlet (live_id,) = row.expect(\"desired-state live roster row missing — bootstrap did not persist\");","preventionTips":["Run the desired-state bootstrap (pgschema apply + reconcile script) before asserting on live rows.","Use fetch_optional + explicit panic message for existence checks.","Clean scratch DBs in setup to avoid deleted_at leftovers.","Assert earlier steps' outputs before querying derived state."],"tags":["rust","test-panic","sqlx","postgres"],"backgroundTag":"row-not-found","analyzedSha":"dad5a33865fc81a2e55b3b60746632f615ec1e3a","analyzedAt":"2026-08-30T13:49:18.474Z","contentChangedAt":"2026-08-30T13:49:18.474Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}