Skip to content

fix(github): retry label and assignee writes on stale installation tokens - #6306

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
bohdansolovie:fix/label-assignee-token-retry-6191
Jul 16, 2026
Merged

fix(github): retry label and assignee writes on stale installation tokens#6306
JSONbored merged 2 commits into
JSONbored:mainfrom
bohdansolovie:fix/label-assignee-token-retry-6191

Conversation

@bohdansolovie

Copy link
Copy Markdown
Contributor

Summary

  • Wraps ensurePullRequestLabel, removePullRequestLabel, and ensurePullRequestAssignee in withInstallationTokenRetry, matching postPullRequestComment, closePullRequest, and the other GitHub-write helpers.
  • Stale cached installation tokens that produce a 401 now get one eviction + remint retry instead of failing the label/assignee mutation permanently while leaving later write helpers to recover alone.
  • Updates the label-only public-surface queue regression for permission-scope 403 retry (2 writers × 2 attempts).
  • Adds regression coverage for both label helpers and the assignee helper (#6191).

Closes #6191

Scope

  • Code changes stay inside the declared surfaces (src/github/labels.ts, src/github/assignees.ts, matching unit tests)
  • No public API / export surface change beyond fixing helper behavior
  • Reuses the existing withInstallationTokenRetry helper — no new retry semantics invented here

Validation

  • Matching unit tests updated (github-labels.test.ts, github-assignees.test.ts, queue-4.test.ts)
  • Focused regression coverage for the exact failure mode called out in #6191
  • CI on this PR (will mark ready after green)

Safety

  • Diff is limited to GitHub label/assignee write retries (+ one queue expectation)
  • No scheme / economics / protocol changes
  • Existing non-401 failure paths (missing privileges, agents, rate limits) still return { applied: false } / throw without inventing success

Made with Cursor

bohdansolovie and others added 2 commits July 16, 2026 02:35
…kens

ensurePullRequestLabel, removePullRequestLabel, and ensurePullRequestAssignee now use withInstallationTokenRetry so a 401 (or scope 403) invalidates the cached token and retries once — matching the other GitHub-write helpers.

Closes JSONbored#6191

Co-authored-by: Cursor <cursoragent@cursor.com>
ensurePullRequestLabel now uses withInstallationTokenRetry, so a
permission-scope 403 remints and retries — doubling the label POST count
in the label-only public-surface failure regression.

Co-authored-by: Cursor <cursoragent@cursor.com>
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 16, 2026
@loopover-orb

loopover-orb Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-16 01:06:14 UTC

5 files · 1 AI reviewer · no blockers · CI green · unstable

⏸️ Suggested Action - Manual Review

Review summary
This PR extends the existing withInstallationTokenRetry wrapper (already used by postPullRequestComment, closePullRequest, and createOrUpdateNamedCheckRun) to ensurePullRequestLabel, removePullRequestLabel, and ensurePullRequestAssignee, closing the gap called out in #6191 where these three helpers minted a token once and failed permanently on a stale-cache 401. The refactor correctly preserves existing dedup/short-circuit logic and the specific error-swallowing branches (422 already_exists, 404 not-on-PR, 403 assigning-agents-not-supported) inside the retried closure so those still return early without triggering an extra remint. The queue-4.test.ts update showing labels going from 2 to 4 confirms that non-401 write failures (a 403 permission-scope error) also trigger a remint+retry under the shared helper, which is pre-existing behavior of withInstallationTokenRetry now correctly inherited by these call sites rather than a new bug.

Nits — 5 non-blocking
  • src/github/labels.ts and assignees.ts: wrapping these paths in withInstallationTokenRetry means a genuine (non-stale-token) permission-scope 403 now costs 2x the GitHub API calls and mints a second token before ultimately failing — worth a one-line note in the PR description since it changes rate-limit budget consumption for the permanently-failing case, even though the retry semantics themselves are inherited unchanged from the shared helper.
  • test/unit/queue-4.test.ts:6135: the updated comment explains the 2x label-write count but doesn't assert on token-mint count directly in this test, so a future regression in withInstallationTokenRetry's retry trigger wouldn't be caught here specifically.
  • test/unit/github-assignees.test.ts: no regression test for the case where the retried token also comes back 401 (permanent failure) to confirm the helper still throws/propagates rather than retrying indefinitely — likely covered by shared withInstallationTokenRetry tests, but worth a pointer comment.
  • Consider adding an assertion on tokenMints alongside the labels:4 count in queue-4.test.ts to lock in the exact remint behavior, not just the resulting write count.
  • A short note in the PR description on the rate-limit/token-mint cost of retrying legitimate (non-stale) 403 failures would help reviewers reason about worst-case GitHub API usage under sustained permission-scope failures.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6191
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 79 registered-repo PR(s), 28 merged, 6 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bohdansolovie; Gittensor profile; 79 PR(s), 6 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Review context
  • Author: bohdansolovie
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 79 PR(s), 6 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add a concise scope and risk note.
  • Then work through the remaining 1 step in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@bohdansolovie
bohdansolovie marked this pull request as ready for review July 16, 2026 00:52
@bohdansolovie
bohdansolovie requested a review from JSONbored as a code owner July 16, 2026 00:52
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 16, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@bohdansolovie

Copy link
Copy Markdown
Contributor Author

@Loopover CI is green on this PR (validate + all test shards + validate-tests-merge). Patch coverage is 100%. Please re-run review with the updated CI status.

@loopover-orb loopover-orb 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.

LoopOver approves — the gate is satisfied and CI is green.

@JSONbored
JSONbored merged commit 01efb3b into JSONbored:main Jul 16, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(github): label/assignee writes skip the installation-token retry every sibling GitHub-write helper uses

2 participants