Skip to content

fix(bitbucket): retain pending checks when a PR watch starts - #44217

Closed
caoergou wants to merge 2 commits into
pingdotgg:mainfrom
caoergou:fix/bitbucket-watch-checks-state
Closed

caoergou wants to merge 2 commits into
pingdotgg:mainfrom
caoergou:fix/bitbucket-watch-checks-state

Conversation

@caoergou

Copy link
Copy Markdown

Problem

Bitbucket reads build statuses but omits their aggregate state from PR details. Watch registration consequently loses pending CI, and a check that passes before the first reactor sweep can be silently baselined without waking the thread.

Change

Return checksState using the existing rollupCheckStatuses helper and the checks already fetched. Distinguish an unavailable check read from a successfully read empty list: retain the existing checks: [] fallback, but omit the aggregate state when the read failed.

The patch changes two files and adds no API requests, authentication methods, settings, or changes to transient-failure recovery.

Scope

Fixes #44202.

This fixes the missing Bitbucket watch seed on current main. Related summary optimization #27596 will also need to preserve fresh check state for watch registration.

Verification

  • vp run check:changed --concurrency 1: format, lint, both knip passes, typechecks for 11 affected packages, and 23 tests across 3 files passed on base 9268aa9b27b3ef1d6be77c2563240bfc21b469ab.
  • The Bitbucket provider's 20 tests pass. The new pending-state regression fails against the original provider (undefined instead of pending). Existing optional-read tests now assert that both response and body-read failures leave checksState absent; those assertions caught and prevented clearing a previously known state.
  • A temporary runtime proof exercised the real Bitbucket provider, summary conversion, watch registration, orchestrator, in-memory persistence, reactor and effect worker, with synthetic external API responses. The unmodified provider produced no notification. The final provider retained pending state and produced one completion notification; a repeated sweep did not repeat it:
Before: registration {"watching":true}
        first sweep []
After:  registration {"watching":true,"checksState":"pending"}
        first sweep ["#1: checks passed"]
        repeated sweep ["#1: checks passed"]

The runtime fixture was removed from the submitted diff after verification. Non-loopback network access was blocked. This is not a newly captured live Bitbucket timing reproduction; repository-wide tests and builds remain for CI.

Two independent reviews covered standards and the requested behavior. The unavailable-read finding was fixed and rechecked.

Implemented with GPT-6.1 Sol in the Codex harness through T3 Code. Independently reviewed with GPT-6.2 Sol in Codex.

Return the aggregate state of checks already read by the provider so watch registration retains pending CI. Keep the state absent after an unavailable check read, preserving existing optional-read behavior.

Fixes: pingdotgg#44202
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Bitbucket provider now preserves whether check data is available and returns an aggregate checksState when it is. Tests cover pending checks and verify that unavailable check data does not produce checksState.

Changes: Bitbucket check status reporting

Layer / File(s) Summary
Return aggregate check status
packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.ts, packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.test.ts
getChangeRequest uses null to represent unavailable check data, returns checks as an array, and adds checksState when check data is available. Tests cover a pending check and the absence of checksState in the rate-limit case.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 32276 concerns repeated checks-passed notifications after a pending read. This change preserves pending status at registration, but does not change the shared watch evaluation behavior identified in that issue.
Merge Risk: Minimal · up to a32b7

Merge Risk: ⚪ Minimal · up to a32b7

Bitbucket PR watches now keep pending CI state at registration, so a later passing result produces one completion notification. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the Bitbucket provider and the core fix, retaining pending checks when a PR watch starts. The change adds checksState derived from the existing checks via rollupCheckStatuses, so pendi…
Description check Passed The description covers Problem, Change, Scope, and Verification, and it links issue #44202 as the bug. It gives concrete verification: check run results, a regression test that fails on the original p…
Linked Issues check Passed [#44202] requires Bitbucket PR details to carry the aggregate check state so that watch registration seeds pending CI. At head, BitbucketPullRequestProvider.getChangeRequest computes checksState with …
Out of Scope Changes check Passed The whole-PR diff (merge base 9268aa9 to head 779b1b3) changes two files, as the PR description states. BitbucketPullRequestProvider.ts adds the rollupCheckStatuses import, the PullRequestCheck type…
Full details: Title check

Explanation

The title names the Bitbucket provider and the core fix, retaining pending checks when a PR watch starts. The change adds checksState derived from the existing checks via rollupCheckStatuses, so pending CI survives watch registration. The title follows the conventional commit format and is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description covers Problem, Change, Scope, and Verification, and it links issue #44202 as the bug. It gives concrete verification: check run results, a regression test that fails on the original provider, and a runtime proof. It also states what was not checked, which the template asks for. Two gaps remain. The Verification section reports a repeated-sweep result that contradicts the claim in the same bullet, since the displayed output shows the notification repeated. The description also does not say whether the agent model line follows the template's requirement. Both are minor, so the description is mostly complete.

Full details: Linked Issues check

Explanation

[#44202] requires Bitbucket PR details to carry the aggregate check state so that watch registration seeds pending CI. At head, BitbucketPullRequestProvider.getChangeRequest computes checksState with rollupCheckStatuses(checks.map(c => c.status)) from the checks already read by listChecks. A pending build check therefore yields checksState 'pending', which PullRequestWatchService.setWatching uses to seed checksPending. The change adds no API calls. The @t3tools/source-control-core dependency already exists in package.json, and the helper is exported from packages/source-control-core/src/server/pullRequestChecks.ts. When listChecks fails, checks falls back to [] and checksState is omitted, as the issue requires. The regression test and the runtime proof in the PR description support the pending-to-success path. I did not re-run the tests. The repeated-sweep no-duplicate behavior depends on existing evaluator code that this PR does not change; the PR objectives flag an ambiguous repeated-sweep output, but this does not change the coding result for the seed requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff (merge base 9268aa9 to head 779b1b3) changes two files, as the PR description states. BitbucketPullRequestProvider.ts adds the rollupCheckStatuses import, the PullRequestCheck type import, the null-sentinel for failed listChecks reads, and the conditional checksState. BitbucketPullRequestProvider.test.ts adds tests for the pending state and for the omitted state on failed reads. Each change supports the [#44202] objective. No unrelated API, auth, setting, or transient-failure recovery changes were found in the reviewed hunks.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4f7c529 and 779b1b3.

Files selected for processing: 2

  • packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.test.ts
  • packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 27, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: a valid Bitbucket account and accessible repository with a controllable PR build are required but unavailable in this worker's configured accounts.
  • Pending-state retention, one wake after successful completion before the first sweep, suppression of repeated notifications, and absent aggregate state after failed status reads were not demonstrated.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 27, 2026
@Yash-Singh1

Copy link
Copy Markdown
Collaborator

Superseded by #44215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bitbucket PR watches lose pending checks at registration and miss the first successful run

3 participants