Skip to content

fix(event): link Event Streams docs when preview access is denied - #15206

Merged
babakks merged 1 commit into
trunkfrom
babakks/event-preview-docs-hint
Dec 1, 2026
Merged

babakks merged 1 commit into
trunkfrom
babakks/event-preview-docs-hint

Conversation

@babakks

@babakks babakks commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Description

Event Streams is in preview, so the API answers every gh event request from an account that isn't enrolled with a 403 and the message "Event subscriptions are not enabled for this account". gh already recognizes that response and says the account isn't enabled, but it leaves the user (or the agent running gh) with no next step.

This adds a final line to that error pointing to the Event Streams documentation, which explains the preview and links to the waitlist signup:

To join the preview waitlist, see: https://gh.io/event-streams-docs

The check that recognizes the preview response is also more robust now. It first looks for an error item with resource EventSubscription and code not_enabled, which the API is adding to this 403 so clients don't have to depend on the message text. For responses without that item, it falls back to the message, matched case-insensitively and as a substring, so a change in casing or surrounding text (such as a trailing period) doesn't silently drop the hint.

How did you test this change?

I built gh from trunk and from this branch and ran both against a local mock API that answers POST /event-subscriptions and GET /event-subscriptions with a 403 and the preview message.

Given the account isn't enrolled in the preview
When I ran gh event listen --resource https://github.com/example.invalid/hello/pull/1 --event pull_request
Then both builds exited 1, and only this branch ended the error with the docs line:

event subscriptions are in preview and not enabled for this account: HTTP 403: Event subscriptions are not enabled for this account (https://api.github.com/event-subscriptions)
To join the preview waitlist, see: https://gh.io/event-streams-docs

Given the same account
When I ran gh event subscription list
Then both builds exited 1, and only this branch ended the error with the same docs line:

failed to list subscriptions: event subscriptions are in preview and not enabled for this account: HTTP 403: Event subscriptions are not enabled for this account (https://api.github.com/event-subscriptions?per_page=30)
To join the preview waitlist, see: https://gh.io/event-streams-docs

I then changed the mock 403 to include the {"resource":"EventSubscription","code":"not_enabled"} error item and replaced its message with a generic "Forbidden", so only the error item identifies the preview response.

Given the account isn't enrolled and the 403 carries only the error item
When I ran gh event subscription list with this branch
Then it exited 1 and still recognized the preview response and printed the docs line:

failed to list subscriptions: event subscriptions are in preview and not enabled for this account: HTTP 403: Forbidden (https://api.github.com/event-subscriptions?per_page=30)
EventSubscription. not_enabled
To join the preview waitlist, see: https://gh.io/event-streams-docs

The EventSubscription. not_enabled line comes from the shared API error formatting, which adds each error item to the message.

I also confirmed that https://gh.io/event-streams-docs redirects to https://docs.github.com/integrations/how-tos/using-github-event-streams.

Key points

  • The hint is added in forbiddenError, which every gh event command goes through, so listen and all subscription commands get it without per-command changes.
  • It follows the existing %w\nTo ... pattern used for the subscription limit hint, so errors.Is(err, client.ErrPreviewNotEnabled) and the wrapped api.HTTPError are unchanged.
  • The link is a gh.io short link rather than the full docs URL. It keeps the output short, which matters when agents read it, and it can be redirected if the docs move without a new gh release.
  • The URL is the last thing on the line, so terminals don't pick up trailing punctuation as part of the link.
  • The error item is read from the Errors field that api.HTTPError already parses, so no extra response parsing is needed. The message fallback keeps gh working against API responses that don't carry the item yet.

Notes for reviewers

Start with forbiddenError, isPreviewNotEnabled and the constants next to previewNotEnabledMessage in pkg/cmd/event/client/client.go. The test changes in client_test.go add a reworded, upper-case message case, an error item case with a generic message, a case where a different error code stays a generic forbidden error, and assert the docs line on every preview-access case.

The commands that print the gh event listen hint (such as gh pr view) are not changed; they still only mention that the preview may not be enabled.

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.
  • An agent will draft replies and @username will read them before they are posted.
  • Nobody has explicitly committed to replying.

@babakks
babakks requested a review from a team as a code owner December 1, 2026 16:28
@babakks
babakks requested review from BagToad and a balanced review from Copilot December 1, 2026 16:28

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

No active review issues block the change adding documentation guidance to preview-access errors.

No open issues 🎉

What changed in this PR

This PR gives users denied access to the Event Streams preview a next step by adding a documentation link to the shared gh event error handler.

Changes:

  • Append a docs link explaining how to join the preview waitlist while preserving wrapped errors.
  • Recognize preview-denial messages case-insensitively and with surrounding text.
  • Extend tests to cover message variations and verify the docs hint on preview-access errors.
File Description
pkg/​cmd/​event/​client/​client.go Adds the preview docs hint and more tolerant denial-message matching.
pkg/​cmd/​event/​client/​client_test.go Tests message variations and the docs hint on preview-denial errors.

Review effort: Balanced

@BagToad BagToad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple conciseness suggestions

Comment thread pkg/cmd/event/client/client.go Resolved
Comment thread pkg/cmd/event/client/client.go Resolved
Comment thread pkg/cmd/event/client/client.go Resolved
@babakks
babakks enabled auto-merge December 1, 2026 16:56
When the API rejects a request because the account is not enrolled in
the Event Streams preview, end the error with a short link to the
Event Streams docs, which include the waitlist signup link.

Recognize the denial by its EventSubscription not_enabled error item,
and fall back to matching the API message case-insensitively as a
substring for responses without the item, so changes in casing or
surrounding text do not hide the hint.

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bbce5a7f-103c-4e67-99c9-2d6dc3f6a02b
@babakks
babakks force-pushed the babakks/event-preview-docs-hint branch from 9f8d488 to c93d922 Compare December 1, 2026 17:06
@babakks
babakks requested a review from BagToad December 1, 2026 17:06
@babakks
babakks merged commit ca8061f into trunk Dec 1, 2026
18 checks passed
@babakks
babakks deleted the babakks/event-preview-docs-hint branch December 1, 2026 17:14
bartsmykla added a commit to bartsmykla/hubdouble that referenced this pull request Dec 2, 2026
The repository list ordered events of the same second by ID, but a merge's
`merged` and `closed` are synthesized with the pull request's ID and the
issue's ID, and the pull request's ID is the larger one, so the list put
`merged` above `closed`. Live GitHub records `merged` first
(`gh api repos/cli/cli/issues/15206/events`: 37857879021 merged and
37857879337 closed, both 2026-12-01T17:14:29Z), so its newest-first list
shows `closed` above `merged`. Events of one second now keep the reverse
of their issue's own list order, and issues tie by ID.

The limit of the list gets its own name beside the repository comment
list whose values it shares. The events test now merges the pull request
and checks that each issue's list, reversed, is its part of the repository
list, and the permission test reads a real event ID.

Signed-off-by: Bart Smykla <bartek@smykla.com>
bartsmykla added a commit to bartsmykla/hubdouble that referenced this pull request Dec 2, 2026
The repository list ordered events of the same second by ID, but a merge's
`merged` and `closed` are synthesized with the pull request's ID and the
issue's ID, and the pull request's ID is the larger one, so the list put
`merged` above `closed`. Live GitHub records `merged` first
(`gh api repos/cli/cli/issues/15206/events`: 37857879021 merged and
37857879337 closed, both 2026-12-01T17:14:29Z), so its newest-first list
shows `closed` above `merged`. Events of one second now keep the reverse
of their issue's own list order, and issues tie by ID.

The limit of the list gets its own name beside the repository comment
list whose values it shares. The events test now merges the pull request
and checks that each issue's list, reversed, is its part of the repository
list, and the permission test reads a real event ID.

Signed-off-by: Bart Smykla <bartek@smykla.com>
bartsmykla added a commit to bartsmykla/hubdouble that referenced this pull request Dec 2, 2026
The repository list ordered events of the same second by ID, but a merge's
`merged` and `closed` are synthesized with the pull request's ID and the
issue's ID, and the pull request's ID is the larger one, so the list put
`merged` above `closed`. Live GitHub records `merged` first
(`gh api repos/cli/cli/issues/15206/events`: 37857879021 merged and
37857879337 closed, both 2026-12-01T17:14:29Z), so its newest-first list
shows `closed` above `merged`. Events of one second now keep the reverse
of their issue's own list order, and issues tie by ID.

The limit of the list gets its own name beside the repository comment
list whose values it shares. The events test now merges the pull request
and checks that each issue's list, reversed, is its part of the repository
list, and the permission test reads a real event ID.

Signed-off-by: Bart Smykla <bartek@smykla.com>
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