block/buzz · error
seed canonical admin
Error message
seed canonical admin
What it means
The test seeds the canonical owner row by INSERTing the community/channel/member/owner binding into the scratch database. The expect panics when the INSERT fails — typically a foreign-key violation (referenced community/channel rows absent), a NOT NULL/unique constraint, or RLS/check constraints rejecting the seed values.
Source
Thrown at crates/buzz-db/src/store/channel_members.rs:3166
let community_uuid = Uuid::new_v4();
let community = CommunityId::from_uuid(community_uuid);
let channel = Uuid::new_v4();
let relay_keys = Keys::generate();
let owner_keys = Keys::generate();
let owner = owner_keys.public_key().to_bytes();
seed_community_channel(&pool, community_uuid, channel, &owner_keys).await;
let member = Keys::generate().public_key().to_bytes();
sqlx::query(
"INSERT INTO channel_members (community_id, channel_id, pubkey, role, invited_by) \
VALUES ($1, $2, $3, 'admin', $4)",
)
.bind(community_uuid)
.bind(channel)
.bind(member.as_slice())
.bind(owner.as_slice())
.execute(&pool)
.await
.expect("seed canonical admin");
let roster = |role: &str, timestamp| {
EventBuilder::new(Kind::Custom(39002), "")
.tags(vec![
Tag::parse(["d", channel.to_string().as_str()]).expect("d tag"),
Tag::parse(["p", hex::encode(owner).as_str(), "", "owner"])
.expect("owner p tag"),
Tag::parse(["p", hex::encode(member).as_str(), "", role])
.expect("member p tag"),
])
.custom_created_at(Timestamp::from(timestamp))
.sign_with_keys(&relay_keys)
.expect("sign roster")
};
let base = Timestamp::now().as_secs();
let fresh = roster("admin", base);
assert!(
db.replace_addressable_event(community, &fresh, Some(channel))View on GitHub (pinned to dad5a33865)
Solutions
- Insert prerequisite community/channel rows before this seed INSERT
- Read the sqlx constraint-violation error to see which FK/unique/CHECK failed and satisfy it
- Compare the INSERT's column list against the current table schema after recent migrations
- If RLS policies apply, run the seed as the table owner or bypass RLS role
Example fix
// before
.bind(owner.as_slice())
.execute(&pool).await.expect("seed canonical admin");
// after
.bind(owner.as_slice())
.execute(&pool).await.unwrap_or_else(|e| panic!("seed canonical admin: {e} — are the community/channel prerequisite rows present?")); Defensive patterns
Strategy: try-catch
Try / catch
.execute(&pool).await
.unwrap_or_else(|e| panic!("seed canonical admin failed: {e} — check FK parents and unique constraints")); Prevention
- Insert parent community/channel rows before member seeds
- Match the INSERT column list to the live table after migrations
- Run seeds as a role that bypasses RLS or is table owner
When it happens
Trigger: INSERT into the roster/channel_members table when the parent channel or community row does not exist yet (FK violation), the member already has a row (unique violation), or a CHECK constraint on role/name fails.
Common situations: Executing the seed before the schema's prerequisite inserts; schema.sql in the scratch DB missing seed DML that production bootstrap applies (per AGENTS.md, pgschema and raw schema application differ); column list drift after a migration added a NOT NULL column.
Related errors
- disable partition roster trigger
- create desired-schema scratch db
- apply desired-state schema
- seed writer member
- seed replica member
AI-assisted analysis of block/buzz@dad5a33865 (2026-08-30).
Data as JSON: /api/errors/3f8d7c5747e2f75d.
Report an issue: GitHub.