Skip to content

Event streaming (10/11): Report a deleted subscription clearly - #15080

Merged
BagToad merged 1 commit into
babakks/event-listen-flushfrom
babakks/event-listen-deleted-sub
Nov 17, 2026
Merged

BagToad merged 1 commit into
babakks/event-listen-flushfrom
babakks/event-listen-deleted-sub

Conversation

@babakks

@babakks babakks commented Nov 17, 2026

Copy link
Copy Markdown
Member

Layer 10 of 11 in the stack tracked by #15070.

Description

When an event subscription is deleted, the server ends every open stream for it with a subscription_ended frame whose reason is deleted. gh event listen had no case for that reason, so it fell through to the generic message, which shows raw protocol values and gives no next step:

event stream ended: subscription_ended (deleted)

This change handles the deleted reason explicitly. The command still exits with status 1 and never creates the subscription again, because deleting a subscription is how its listeners are stopped on purpose. The advice depends on how the subscription was chosen:

  • With --resource, the command created the subscription itself, so it suggests running the command again to create a new one:
    subscription sub_a22660aa… was deleted
    To keep listening, run the command again to create a new subscription.
    
  • With --subscription, it reuses the existing advice to listen with --resource and the same --event types, as it already does for an expired subscription.

docs/event-listen-preview.md now states that a deleted subscription is final in both modes.

How did you test this change?

I built gh from this branch and ran both cases against a pull request in a test repository. The attached video records both runs. Each case ends with echo "exit status: $?" so the exit status is visible.

  1. Given no merge conflict subscription existed, when I ran gh event listen --resource <pr> --event com.github.pull_request.merge_conflict.v1 and a background job deleted the new subscription 20 seconds later, then I saw subscription sub_… was deleted followed by To keep listening, run the command again to create a new subscription., and the exit status was 1. gh event subscription view then reported the subscription as not found.
  2. Given I had created the same subscription with gh event subscription create, when I ran gh event listen --subscription <id> and a background job deleted it 20 seconds later, then I saw subscription sub_… was deleted followed by the advice to run the command again with --resource and the same --event types, and the exit status was 1. gh event subscription view then reported the subscription as not found.

Before this change, the same deletion in --resource mode printed event stream ended: subscription_ended (deleted) and exited with status 1.

10-listen-deleted-sub.mp4

Key points

  • In --resource mode, an expired subscription is created again automatically, but a deleted one is not. Recreating it would make deletion useless as a way to stop listeners.
  • The exit status stays 1, matching the other endings that stop listening without an event, so scripts can still tell that no event arrived.

Notes for reviewers

Start with the new deleted case in the stream end switch in pkg/cmd/event/listen/listen.go, then the two table cases in listen_test.go covering each mode.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @babakks will read and reply directly. Name the account.
  • An agent will draft replies and @babakks will read them before they are posted.
  • Nobody has explicitly committed to replying.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: bbce5a7f-103c-4e67-99c9-2d6dc3f6a02b
@babakks
babakks requested a review from a team as a code owner November 17, 2026 17:11
@babakks
babakks requested review from sergiou87 and a balanced review from Copilot and removed request for a team November 17, 2026 17:11
@babakks
babakks added this pull request to stack #15082 November 17, 2026 17:14

Copilot AI 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.

🟢 Approval recommended

The deleted-subscription handling change has no active review issues blocking approval.

No open issues 🎉

What changed in this PR

This layer of the event-streaming stack improves how gh event listen reports a deleted subscription, replacing raw protocol details with actionable advice.

Changes:

  • Adds deletion-specific messages tailored to --resource and --subscription, preserving exit status 1 and stopping without recreating the subscription.
  • Adds tests covering deletion in both listening modes.
  • Documents that deletion ends listening in both modes.
File Description
pkg/​cmd/​event/​listen/​listen.go Handles deleted subscriptions with mode-specific recovery advice.
pkg/​cmd/​event/​listen/​listen_test.go Tests deletion messages and subscription creation behavior.
docs/​event-listen-preview.md Clarifies that deletion is final in both modes.

Review effort: Balanced

@babakks
babakks requested review from BagToad and removed request for sergiou87 November 17, 2026 17:16
@BagToad
BagToad merged commit 42d52b4 into trunk Nov 17, 2026
19 checks passed
@BagToad
BagToad deleted the babakks/event-listen-deleted-sub branch November 17, 2026 19:18
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.

3 participants