block/buzz · error

load desired-state live roster

Error message

load desired-state live roster

What it means

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.

Solutions

  1. Verify the earlier steps of the test succeeded (fresh.id matches what was published) before this query.
  2. Check that the desired-state bootstrap wrote the roster with deleted_at NULL for this community/channel.
  3. 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.
  4. If row conflicts arise from re-runs, clean the scratch DB in setup instead of relying on unique timestamps.

Example fix

// before
let (live_id,) = sqlx::query_as::<_, (Vec<u8>,)>(q).bind(community_uuid).bind(channel).fetch_one(&pool).await.expect("load desired-state live roster");
// after
let row = sqlx::query_as::<_, (Vec<u8>,)>(q).bind(community_uuid).bind(channel).fetch_optional(&pool).await
    .expect("query live roster");
let (live_id,) = row.unwrap_or_else(|| panic!("no live kind:39002 roster for community {community_uuid} channel {channel}"));
Defensive patterns

Strategy: validation

Validate before calling

// check the row exists before the strict fetch_one
let exists = sqlx::query(
    "SELECT EXISTS(SELECT 1 FROM events WHERE community=$1 AND channel=$2 AND kind=39002 AND deleted_at IS NULL)"
).bind(community_uuid).bind(channel).fetch_one(&pool).await.expect("roster existence probe");
assert!(exists.get::<bool, _>(0), "desired-state bootstrap must persist a live kind:39002 roster");

Try / catch

let row = sqlx::query_as::<_, (Vec<u8>,)>(q).bind(community_uuid).bind(channel)
    .fetch_optional(&pool).await.expect("query live roster");
let (live_id,) = row.expect("desired-state live roster row missing — bootstrap did not persist");

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

Thrown at crates/buzz-db/src/store/channel_members.rs:3207

        let stale = roster("member", base + 1);
        let error = db
            .replace_addressable_event(community, &stale, Some(channel))
            .await
            .expect_err("desired-state fence must reject stale role");
        assert!(matches!(
            error,
            DbError::Sqlx(sqlx::Error::Database(ref db_error))
                if db_error.code().as_deref() == Some("23514")
        ));
        let live_id: Vec<u8> = sqlx::query_scalar(
            "SELECT id FROM events WHERE community_id=$1 AND channel_id=$2 \
             AND kind=39002 AND deleted_at IS NULL",
        )
        .bind(community_uuid)
        .bind(channel)
        .fetch_one(&pool)
        .await
        .expect("load desired-state live roster");
        assert_eq!(live_id, fresh.id.as_bytes().to_vec());

        drop_scratch_db(&admin, pool, &scratch_name).await;
    }
}

View on GitHub (pinned to dad5a33865)