fix(relay): stop panic when reacting to a project root or comment - #4973
fix(relay): stop panic when reacting to a project root or comment#4973BradGroux wants to merge 2 commits into
Conversation
|
Review update: I traced the insert and duplicate control flow, corrected the PR description, and pushed the required formatting cleanup. The functional fix remains narrowly scoped to trace-action construction. A normal retry of the same active reaction exits earlier through At |
A kind:7 reaction targeting a project event (kind 1621 issue, 1618 PR, or a kind-1 comment on one) carries no h tag, so derive_reaction_channel returns NoChannel and channel_id is None. The reaction path's conformance trace emission asserted channel_id was always Some via expect(), which panicked the tokio worker. The reaction row was already stored before the panic, so retries hit the duplicate branch and panicked again — head-of-line blocking for durable-queue clients like buzz-acp. Extract the three-way (channel_id, was_inserted) match into a shared write_trace_action helper used by both the reaction path and the general message-write path, so the two seams cannot diverge. Add regression tests for all four combinations. Refs block#4936 Co-authored-by: Brad Groux <bradgroux@hotmail.com> Signed-off-by: Brad Groux <bradgroux@hotmail.com> Signed-off-by: npub17q2gdupkvswvk5kprwc7plergm4gn295uw6fe4mjyjv53ahuhtnq02jd3f <f01486f036641ccb52c11bb1e0ff2346ea89a8b4e3b49cd772249948f6fcbae6@digitalmeld.communities.buzz.xyz>
Co-authored-by: Brad Groux <bradgroux@hotmail.com> Signed-off-by: Brad Groux <bradgroux@hotmail.com> Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
f611f96 to
639c8c2
Compare
Rebase and accuracy review (2026-08-07)Rebased onto current Branch state: Accuracy reviewThe fix addresses a real panic: reactions (kind 7) on project events (issues, PRs, comments) derive The resolution extracts the three-way No Closes #4936. |
What users saw
Tapping a reaction on an issue, pull request, or a comment on one could panic the relay's ingest worker. The reaction row was inserted before the panic, so the original publisher could see a failed request even though the event had already been persisted.
Why it happened
Reactions (NIP-25, kind 7) derive their channel scope from the target event. Project events such as issues and pull requests do not carry an
htag, soderive_reaction_channelreturnsNoChannelandchannel_idisNone.The conformance-trace emission on the reaction path assumed
channel_idwas always present:That assumption predates reactions on project events. Because persistence completes before the trace action is built, the panic happens after the database write.
What changed
Extracted the three-way
(channel_id, was_inserted)match already used by the general message-write path into a sharedwrite_trace_actionhelper:(Some(ch), true)becomesWriteInsert(Some(ch), false)becomesWriteDuplicate(None, _)becomesWriteInsertGlobalBoth the reaction path and the message-write path now call this helper. Channel-less project reactions use the existing global-write trace vocabulary instead of unwrapping a missing channel.
How this was tested
Added four unit tests covering the complete helper matrix:
WriteInsertGlobalWriteInsertGlobalWriteInsertWriteDuplicateThe channel-less insert is the exact affected path. A normal retry of the same active reaction exits earlier through
ReactionEventInsertOutcome::Duplicate; the channel-less duplicate case is defensive coverage for the helper contract rather than a claim about that retry path.Validation at
f611f96e7:All 164 ingest tests passed, and formatting and strict Clippy checks completed successfully.
Scope and non-goals
Closes #4936.