Skip to content

fix(relay): stop panicking the ingest worker on reactions to project events - #5294

Open
Chessing234 wants to merge 1 commit into
block:mainfrom
Chessing234:fix/relay-reaction-project-root-panic-4936
Open

fix(relay): stop panicking the ingest worker on reactions to project events#5294
Chessing234 wants to merge 1 commit into
block:mainfrom
Chessing234:fix/relay-reaction-project-root-panic-4936

Conversation

@Chessing234

@Chessing234 Chessing234 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

A NIP-25 reaction whose target is a project root or project comment (kind
1621 issue, 1618 PR, or a kind-1 comment on one) carries no h tag, so
channel_id is None on the reaction write path. The conformance-trace
emission asserted a channel was always present:

channel: channel_label(channel_id.expect("reaction path has channel")),

so the worker panicked at ingest.rs:2824. The row was inserted before the
panic, so the client saw a failed request for a persisted event and retried,
and the duplicate branch carried the same expect, head-of-line blocking a
durable publish queue forever.

Mirror the message write's three-way split at the same seam:
(Some, true) -> WriteInsert, (Some, false) -> WriteDuplicate, (None, _)
-> WriteInsertGlobal. The conformance vocabulary already models channel-less
writes; only the reaction path was missing it.

Closes #4936

@Chessing234
Chessing234 requested a review from a team as a code owner August 8, 2026 06:07
@Chessing234
Chessing234 force-pushed the fix/relay-reaction-project-root-panic-4936 branch from 6dc523d to 7432464 Compare August 8, 2026 13:12
@ravarora2

Copy link
Copy Markdown
Contributor

🤖 Tested locally end-to-end — LGTM. ✅

Reproduced the panic on main and confirmed the fix resolves it:

Before (buggy main): published a global kind:1 note (no h tag → channel_id = NULL) and reacted to it. The ingest worker panicked:

thread 'tokio-rt-worker' panicked at crates/buzz-relay/src/handlers/ingest.rs:2849:51:
reaction path has channel

Postgres confirmed the exact failure mode described in the PR: the reaction row was persisted before the panic, so the client's retry hit the Duplicate branch and surfaced a misleading duplicate: reaction already exists.

After (this branch): same steps —

  • publish global note → accepted: true
  • react once → accepted: true (no panic)
  • react again → accepted: false "duplicate" (correct no-op, no panic)
  • panics in relay log: 0

The three-way match (channel_id, was_inserted) routing the channel-less case to WriteInsertGlobal is the right call, and it mirrors the existing message write path. The #[ignore]d regression test (test_reaction_to_channel_less_event_is_accepted) is the automated form of exactly what I ran by hand.

…events

A NIP-25 reaction whose target is a project root or project comment (kind
1621 issue, 1618 PR, or a kind-1 comment on one) carries no h tag, so
channel_id is None on the reaction write path. The conformance-trace
emission asserted a channel was always present:

    channel: channel_label(channel_id.expect("reaction path has channel")),

so the worker panicked at ingest.rs:2824. The row was inserted before the
panic, so the client saw a failed request for a persisted event and retried,
and the duplicate branch carried the same expect, head-of-line blocking a
durable publish queue forever.

Mirror the message write's three-way split at the same seam:
(Some, true) -> WriteInsert, (Some, false) -> WriteDuplicate, (None, _)
-> WriteInsertGlobal. The conformance vocabulary already models channel-less
writes; only the reaction path was missing it.

Closes block#4936

Signed-off-by: Taksh <takshkothari09@gmail.com>
Signed-off-by: Ravneet Arora <rarora@squareup.com>

@ravarora2 ravarora2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ravarora2
ravarora2 force-pushed the fix/relay-reaction-project-root-panic-4936 branch from 7432464 to 1edf6c2 Compare August 11, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

relay: a reaction on a project root (issue/PR) panics the ingest worker

2 participants