fix: mail send prefix mismatch — generate database-prefixed IDs#2211
fix: mail send prefix mismatch — generate database-prefixed IDs#2211DreadPirateRobertz wants to merge 1 commit intogastownhall:mainfrom
Conversation
gt mail send was generating message IDs with "msg-" prefix, but the HQ beads database enforces "hq-" prefix, causing all mail sends to fail with "prefix mismatch: database uses 'hq-' but ID 'msg-...' doesn't match". Root cause: GenerateID() always produced "msg-*" IDs regardless of the target database prefix. The --id flag was passed to bd create to work around an ephemeral insert bug, but the generated ID didn't match the database's prefix constraint. Fix: Add GeneratePrefixedID() that reads the database prefix from metadata.json and generates correctly-prefixed IDs (e.g., "hq-wisp-*" for HQ wisps). Updated sendToSingle() in the mail router and the handoff direct-create path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
DreadPirateRobertz
left a comment
There was a problem hiding this comment.
Reviewed — clean, well-scoped fix.
Root cause correctly identified: GenerateID() produces msg-* IDs but HQ database enforces hq-* prefix validation. GeneratePrefixedID(prefix, isWisp) properly generates database-compatible IDs.
Code looks correct:
sendToSingle()conditionmsg.ID == "" || strings.HasPrefix(msg.ID, "msg-")correctly overwrites pre-existing invalidmsg-*IDs- Both
sendToSingleandsendHandoffMailpaths are fixed ConfigPrefixFromDirwith"hq"fallback is safe for HQ-only mail routing
Minor nit (non-blocking): readBeadsPrefix in router.go is a one-liner wrapper around beads.ConfigPrefixFromDir — could call it directly. Not worth blocking.
LGTM.
DreadPirateRobertz
left a comment
There was a problem hiding this comment.
Code Review: PR #2211 — Mail Send Prefix Mismatch Fix
Reviewed by: zhora (crew)
RECOMMEND CLOSE. This bug was already fixed on main (commit 0b091f2) via a cleaner approach: removing explicit --id from bd create entirely. This PR would reintroduce --id and conflict with the merged fix. PR is in CONFLICTING state confirming this.
|
Closing — the prefix mismatch issue has been resolved differently on main. The mail router now lets bd auto-generate IDs with the correct prefix instead of passing explicit --id flags. The GenerateID() function is only used for in-memory tracking, not persisted to beads. |
Summary
gt mail sendwas broken — all sends failed with "prefix mismatch: database uses 'hq-' but ID 'msg-...' doesn't match"GenerateID()always producedmsg-*IDs but HQ database requireshq-prefixGeneratePrefixedID()that reads the database prefix from metadata.jsonsendToSingle()in mail router and thehandoffdirect-create pathTest plan
gt mail send overseer/ -s "Test" -m "Test"succeeds (was failing before)hq-wisp-*IDsgo test ./internal/mail/...go test ./internal/beads/...🤖 Generated with Claude Code