fix(gastown): distinguish null causes in PR status polling (#3149)#3160
Merged
jrf0110 merged 6 commits intoMay 11, 2026
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Previously Flagged Issues — All Resolved ✓
Latest Commit — No New IssuesThe new commit adds:
Files Reviewed
Reviewed by claude-4.6-sonnet-20260217 · 1,297,610 tokens |
This was referenced May 10, 2026
added 6 commits
May 11, 2026 15:39
Replace PRStatusResult | null return type with discriminated PRStatusOutcome union in checkPRStatus. Each null cause (no token, HTTP error, invalid response, unrecognized URL, host mismatch) now surfaces a structured PRStatusError with actionable failure messages. - resolveGitHubToken returns GitHubTokenResolution with resolution chain - no_token and non-transient HTTP errors (401/403/404) fail immediately - invalid_response/unrecognized_url/host_mismatch fail after 3 strikes - Transient HTTP errors (5xx/429) keep existing 10-strike behavior - poll_null_count resets to 0 on successful poll at both call sites - failureKind persisted to bead metadata for analytics - AE event pr.poll_failed emitted on terminal failure - Unit tests for checkPRStatus, resolveGitHubToken, failureMessageFor, and threshold logic - Integration test for no_token immediate-fail path
… (review on town-scm.ts:66) When integrationId is set but GIT_TOKEN_SERVICE binding is missing, the configured integration source was silently omitted from the tried array. Add an else branch that pushes the source label with a '(GIT_TOKEN_SERVICE not bound)' annotation so the no_token error message lists all attempted sources.
… (review on actions.ts:374) Both are deterministic configuration errors that cannot self-resolve on retry. Move them from the 3-strike bucket to the fail-immediately bucket alongside no_token and non-transient http_error. Only invalid_response remains in the 3-strike category.
…ll errors (review on actions.ts:1350) Replace the shared poll_null_count with poll_transient_count and poll_non_transient_count. Each error category increments only its own counter and resets the other, preventing cross-contamination where 9 transient errors followed by 1 non-transient error would incorrectly fail the bead. Legacy poll_null_count is migrated on first read: the transient branch falls back to poll_null_count when poll_transient_count is absent. This ensures in-flight beads at deploy time retain their existing counter value. The non-transient branch does not read the legacy field since these counters reset on every success anyway — at worst an in-flight bead gets one extra retry for invalid_response.
…aging priority with PR #3160 structured return type - resolveGitHubToken now uses staging's priority: cli_pat → integration → stored token - Returns GitHubTokenResolution discriminated union (from PR #3160) - Includes unbound-service else branch (GIT_TOKEN_SERVICE not bound) - Adds resolveGitHubTokenString helper for non-error-aware callers - Updates Town.do.ts, container-dispatch.ts, config.ts to use helper - Updates town-scm.test.ts for GitHubTokenResolution return shape - Updates pr-poll-errors.test.ts for new priority order
3d397ce to
6dbed96
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
PRStatusResult | nullreturn type with discriminatedPRStatusOutcomeunion incheckPRStatus. Each null cause (no token, HTTP error, invalid response, unrecognized URL, host mismatch) now surfaces a structuredPRStatusErrorwith actionable failure messages.Key changes:
resolveGitHubTokenreturnsGitHubTokenResolutionwith resolution chain tracking which sources were triedno_tokenand non-transient HTTP errors (401/403/404) fail the bead immediately (1 strike)invalid_response/unrecognized_url/host_mismatchfail after 3 strikespoll_null_countresets to 0 on successful poll at both call sitesfailureKindpersisted to bead metadata for analyticspr.poll_failedemitted on terminal failureAlso includes an unrelated fix for boot hydration contention on
/agents/start(commit2ffcef28f).Fixes #3149.
Verification
pnpm --filter cloudflare-gastown typecheckpassestest/unit/pr-poll-errors.test.ts(checkPRStatus, resolveGitHubToken),test/unit/pr-poll-thresholds.test.ts(failureMessageFor, shouldFailImmediately, shouldCountAsTransient)test/integration/pr-poll-errors.test.tsVisual Changes
N/A
Reviewer Notes
refresh-git-token.handler.tschange is a caller update for the newGitHubTokenResolutionreturn type (wasstring | null)2ffcef28f) is included on this branch from a prior bead attempt — it fixes a separate timeout regressionwrangler.jsoncmax_instances change (800→500) is from the same unrelated commit