fix(relay): stop panic when reacting to a project root or comment - #4973
Open
BradGroux wants to merge 2 commits into
Open
fix(relay): stop panic when reacting to a project root or comment#4973BradGroux wants to merge 2 commits into
BradGroux wants to merge 2 commits into
Conversation
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>
Author
|
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 |
wesbillman
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.