Skip to content

Re-probe gh auth in the github plugin instead of latching needs-configuration - #1797

Merged
SawyerHood merged 2 commits into
mainfrom
bb/draft-pr-for-1758-github-plugin-latches-needs-co-thr_rsmx4uwxth
Aug 18, 2026
Merged

SawyerHood merged 2 commits into
mainfrom
bb/draft-pr-for-1758-github-plugin-latches-needs-co-thr_rsmx4uwxth

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

The github plugin ran gh auth status once at load and treated every failure as NeedsConfigurationError. gh auth status calls the GitHub API, so it also fails when the network is down, the keychain is locked, or a slow host exceeds the 10 s timeout. The load-time probe called bb.status.needsConfiguration, and the first pass of the sync background service threw the same error, which the plugin runtime treats as "stop this service until reload". After that nothing ran gh auth status again. bb plugin list showed needs-configuration (GitHub CLI is not authenticated … run gh auth login …) for hours while gh auth status succeeded in every terminal, and only bb plugin reload github recovered. Report: https://get-bb.github.io/reports/issues/1758.html

What changed

plugins/github/server.ts:

  • checkAuth() throws NeedsConfigurationError only when gh is missing or holds no credentials at all. It uses the network-free gh auth token to tell "not logged in" from "logged in but the API probe failed". Every other failure is a typed GhUnavailableError that carries gh's stderr. Both commands are scoped to the active github.com account (--hostname github.com --active), so a broken secondary account cannot block a valid one.
  • Concurrent callers share one in-flight probe promise, so the panel header and body do not spawn duplicate gh processes.
  • The sync service catches only GhUnavailableError inside its loop and retries with backoff (30 s, doubling up to the 5-min interval). Any other error surfaces to the plugin host as before. The plugin-level retry is needed because the host stops a service that crashes during activation instead of restarting it.
  • A sync pass where every repo failed throws GhUnavailableError: the sync time does not advance and the short retry applies. Partial success is still a pass.
  • The status RPC re-runs checkAuth() when the last probe was not ready and returns a typed ghState (ready | needs_configuration | unavailable).
  • Load time calls bb.status.needsConfiguration only for the two genuine configuration cases and logs a transient failure.

plugins/github/app.tsx: the panel shows "GitHub CLI unavailable — retrying" / "GitHub CLI could not reach GitHub …" for unavailable instead of the gh auth login remedy.

Deviation from the report: --hostname github.com --active scoping, the typed ghState, the in-flight probe dedupe, and the all-repos-failed rule come from the SlopCop review. Follow-ups still out of scope: make resolveGh() distinguish ENOENT from a timeout, and a degraded/clear status API in the plugin runtime.

Tests

plugins/github/server.auth-latch.test.ts drives the real plugin entry through createFakePluginHost with a fake gh on PATH:

  • re-probes gh after a transient auth-status failure instead of latching — fails on main
  • does not report needs-configuration for a transient probe failure — fails on main
  • still reports needs-configuration when gh has no credentials at all
  • control: gh working from the start never reports needs-configuration
  • probes only the active github.com account, so a broken secondary account does not block sync — fails before the review fixes
  • shares one in-flight probe between concurrent status calls — fails before the review fixes
  • treats a pass where every repo failed as a failure and keeps the old sync time — fails before the review fixes

How I verified

  • pnpm exec turbo run typecheck test --filter=bb-plugin-github --force → 3 tasks successful, 14 tests passed

Fixes #1758

AGENT GENERATED: by Claude Opus 5

@SawyerHood
SawyerHood marked this pull request as ready for review August 18, 2026 18:23
@bb-slop-cop

bb-slop-cop Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am reviewing this pull request now. In plain English, it changes the GitHub plugin so a temporary authentication check failure does not disable the plugin until a reload.

I will check security, code quality, performance, architecture, and the relevant user flow.

Comment thread plugins/github/server.ts
try {
await syncAll();
failures = 0;
} catch (error) {

@bb-slop-cop bb-slop-cop Bot Aug 18, 2026 •

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.

🚨 slopcop/review — This catch hides faults that the plugin host must handle.

The catch accepts every error except NeedsConfigurationError. Database, storage, SDK, and programming faults now look like temporary sync failures.

The plugin runtime already restarts failed services with capped backoff. It also records service failures and stops restarts for configuration errors.

Please remove this duplicate retry loop, or catch a specific temporary authentication error. Let all other errors reach the host.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 0334e52: the loop now retries only a typed GhUnavailableError (gh has credentials but a network-dependent step failed); every other error rethrows to the host. The plugin-level retry stays because the host stops a service that crashes during activation instead of restarting it.

Comment thread plugins/github/server.ts Outdated
// timeout) is a plain Error so callers retry instead of latching (#1758).
async function checkAuth(): Promise<void> {
try {
await gh(["auth", "status"], 10_000);

@bb-slop-cop bb-slop-cop Bot Aug 18, 2026 •

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.

🚨 slopcop/review — These two authentication checks can inspect different accounts.

gh auth status checks every account on every known host by default. It exits with code 1 when any account has a problem.

gh auth token then checks only the active account on the default host. An invalid secondary account can therefore stop a valid github.com sync forever.

Please scope both commands to the active github.com account. Add a test with one valid active account and one invalid secondary account.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 0334e52: both commands run as gh auth status --hostname github.com --active and gh auth token --hostname github.com; test "probes only the active github.com account" covers a broken secondary account.

Comment thread plugins/github/server.ts Outdated
async status() {
// Re-probe on demand after a failed probe so a recovered gh is noticed
// the next time the panel or CLI asks, not only on the next sync tick.
if (ghAuthError !== null) {

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.

🚨 slopcop/review — Concurrent status calls start duplicate authentication probes.

The header and panel each call useStatus() when the panel opens. Both RPC calls enter this branch while ghAuthError is set.

One panel can start two gh auth status processes and two gh auth token processes. More windows multiply this work.

Please share one active probe promise, or add a short failure delay. A concurrent RPC test will protect this path.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 0334e52: checkAuth() shares one in-flight probe promise; test "shares one in-flight probe between concurrent status calls" asserts a single gh auth status process for two concurrent status RPCs.

Comment thread plugins/github/server.ts
if (ghAuthError !== null) {
try {
await checkAuth();
} catch {

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.

🚨 slopcop/review — A temporary failure still produces the wrong user instruction.

This catch keeps ghAuthError, so the RPC returns ghOk: false. The current panel then says authentication is missing.

It also tells the user to run gh auth login and reload the plugin. That is the false remedy this change tries to remove.

Please return a typed state for ready, needs_configuration, and temporarily_unavailable. Then show a retry message for temporary failures.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 0334e52: the status RPC returns a typed ghState (ready | needs_configuration | unavailable) and app.tsx shows a retry message for unavailable instead of the gh auth login remedy.

Comment thread plugins/github/server.ts
await syncAll();
let delayMs = SYNC_INTERVAL_MS;
try {
await syncAll();

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.

🚨 slopcop/review — Repository failures do not use this retry policy.

syncAll() catches each repository error and still returns success. This loop then resets failures and waits five minutes.

The code also writes a new sync time after every repository fails. The panel can therefore present old data as current.

Please report a failed pass when no repository completes. Keep partial success, but do not move the sync time after total failure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 0334e52: syncAll() throws GhUnavailableError when every repo failed, so the sync time does not advance and the short retry applies; partial success still counts as a pass. Test "treats a pass where every repo failed as a failure" covers it.

@bb-slop-cop bb-slop-cop Bot 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.

🚨 SLOP COP 🚨 · review

Plain English summary: This change lets the GitHub plugin test authentication again after a temporary failure. It no longer treats every failed test as missing credentials.

I found five issues:

  1. The new catch hides database, storage, SDK, and code faults. The plugin host already owns service restart and backoff policy.
  2. The two GitHub CLI commands can inspect different hosts and accounts. One bad secondary account can stop a valid active account.
  3. The panel header and body can start duplicate authentication processes at the same time.
  4. A temporary failure still tells the user to authenticate again and reload the plugin.
  5. Repository failures return success, advance the sync time, and bypass the new short retry delay.

The architecture scan found no second GitHub authentication module. It did find duplicate retry policy between this plugin and the plugin runtime.

The security review found no security issue. The code uses execFile with argument arrays, and it does not return authentication output.

Validation passed for the exact head commit:

  • All 11 GitHub plugin tests passed.
  • The Turbo typecheck passed.
  • All GitHub CI checks passed.
  • A clean development server started from this commit.
  • The GitHub panel loaded in a browser and showed a healthy status.
  • The Refresh control completed without an error.

I would fix the catch-all retry and the command scope before merge. I left detailed comments on each affected line.

SawyerHood and others added 2 commits August 18, 2026 19:46
The github plugin ran gh auth status once at load and mapped every failure to
NeedsConfigurationError. That latched needs-configuration for a network blip,
a locked keychain, or a slow host until the user reloaded the plugin.

- checkAuth() only throws NeedsConfigurationError when gh is missing or holds
  no credentials (network-free gh auth token); other failures are plain errors.
- The sync service retries transient failures with backoff instead of stopping.
- The status RPC re-probes gh when the last probe failed.
- Load-time only calls bb.status.needsConfiguration for genuine config cases.

Fixes #1758

Co-Authored-By: Claude <[email protected]>
… account

Address SlopCop review on #1797:
- Only GhUnavailableError (gh has credentials but a network-dependent step
  failed) is retried inside the sync service; other errors surface to the host.
- Scope gh auth status/token to the active github.com account so a broken
  secondary account cannot block a valid one.
- Share one in-flight auth probe between concurrent status RPCs.
- Report a typed ghState (ready | needs_configuration | unavailable) and show a
  retry message in the panel for transient failures.
- A sync pass where every repo failed is a failure: no sync time advance, and
  the short retry applies.

Co-Authored-By: Claude <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/draft-pr-for-1758-github-plugin-latches-needs-co-thr_rsmx4uwxth branch from b67bc59 to 0334e52 Compare August 18, 2026 19:50
@SawyerHood
SawyerHood merged commit a9dd53f into main Aug 18, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/draft-pr-for-1758-github-plugin-latches-needs-co-thr_rsmx4uwxth branch August 18, 2026 21:16
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.

github plugin latches needs-configuration on one transient gh auth failure and never re-probes

1 participant