Repository navigation
Re-probe gh auth in the github plugin instead of latching needs-configuration - #1797
Conversation
|
🚨 SLOP COP 🚨 · 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. |
| try { | ||
| await syncAll(); | ||
| failures = 0; | ||
| } catch (error) { |
There was a problem hiding this comment.
🚨 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.
There was a problem hiding this comment.
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.
| // timeout) is a plain Error so callers retry instead of latching (#1758). | ||
| async function checkAuth(): Promise<void> { | ||
| try { | ||
| await gh(["auth", "status"], 10_000); |
There was a problem hiding this comment.
🚨 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.
There was a problem hiding this comment.
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.
| 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) { |
There was a problem hiding this comment.
🚨 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.
There was a problem hiding this comment.
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.
| if (ghAuthError !== null) { | ||
| try { | ||
| await checkAuth(); | ||
| } catch { |
There was a problem hiding this comment.
🚨 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.
There was a problem hiding this comment.
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.
| await syncAll(); | ||
| let delayMs = SYNC_INTERVAL_MS; | ||
| try { | ||
| await syncAll(); |
There was a problem hiding this comment.
🚨 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
🚨 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:
- The new catch hides database, storage, SDK, and code faults. The plugin host already owns service restart and backoff policy.
- The two GitHub CLI commands can inspect different hosts and accounts. One bad secondary account can stop a valid active account.
- The panel header and body can start duplicate authentication processes at the same time.
- A temporary failure still tells the user to authenticate again and reload the plugin.
- 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.
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]>
b67bc59 to
0334e52
Compare
What was wrong
The github plugin ran
gh auth statusonce at load and treated every failure asNeedsConfigurationError.gh auth statuscalls 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 calledbb.status.needsConfiguration, and the first pass of thesyncbackground service threw the same error, which the plugin runtime treats as "stop this service until reload". After that nothing rangh auth statusagain.bb plugin listshowedneeds-configuration (GitHub CLI is not authenticated … run gh auth login …)for hours whilegh auth statussucceeded in every terminal, and onlybb plugin reload githubrecovered. Report: https://get-bb.github.io/reports/issues/1758.htmlWhat changed
plugins/github/server.ts:checkAuth()throwsNeedsConfigurationErroronly when gh is missing or holds no credentials at all. It uses the network-freegh auth tokento tell "not logged in" from "logged in but the API probe failed". Every other failure is a typedGhUnavailableErrorthat carries gh's stderr. Both commands are scoped to the activegithub.comaccount (--hostname github.com --active), so a broken secondary account cannot block a valid one.ghprocesses.syncservice catches onlyGhUnavailableErrorinside 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.GhUnavailableError: the sync time does not advance and the short retry applies. Partial success is still a pass.statusRPC re-runscheckAuth()when the last probe was notreadyand returns a typedghState(ready|needs_configuration|unavailable).bb.status.needsConfigurationonly 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 …" forunavailableinstead of thegh auth loginremedy.Deviation from the report:
--hostname github.com --activescoping, the typedghState, the in-flight probe dedupe, and the all-repos-failed rule come from the SlopCop review. Follow-ups still out of scope: makeresolveGh()distinguish ENOENT from a timeout, and a degraded/clear status API in the plugin runtime.Tests
plugins/github/server.auth-latch.test.tsdrives the real plugin entry throughcreateFakePluginHostwith a fakeghon PATH:How I verified
pnpm exec turbo run typecheck test --filter=bb-plugin-github --force→ 3 tasks successful, 14 tests passedFixes #1758