Repository navigation
fix: read a withdrawn bitbucket server approval as withdrawn - #39431
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a mechanism-level fix with a linked live reproduction (#21122), and a test added here fails on base. What this change shipsInventory (3 items) — 3 justifiedIntent: a Bitbucket Server reviewer who withdraws an approval stops showing as approved in the pull-request read. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 11c3fb8 Description read[DESCRIPTION-READ] e74ea47e5d0be902c4d0966cc49a50b390cb22fcc41cbb1f43ada378accafef7 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: a withdrawal is now replayed within the activity stream the reader already folds, and it is keyed by the reviewer's account. Notes
[DESIGN-REVIEWED] 11c3fb8 Description read[DESCRIPTION-READ] 19252e1e51589e6460be42ca3ebc3482222cfa0b1150d808d0ed38e4cf3f9592 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
79967bf to
d9e1949
Compare
|
Rebased: main moved in 108 files this PR's files import or sit beside ( The only red on the old head was |
The Bitbucket Server reader flattens the pull request's activity stream into review rows, but mapped only APPROVED and REVIEWED and ignored UNAPPROVED. A reviewer who approved and then withdrew therefore still read as APPROVED, while the instance itself reads them as having no verdict. When an UNAPPROVED activity arrives, drop that reviewer's earlier review rows. The reviewer is identified by the account name (else slug), not the display name, since two accounts can share one. A later re-approval still yields its own row; other reviewers and comment rows are untouched. The test serves the activity stream from the live run on Bitbucket Data Center 9.4.26 reported in #21122, plus the REVIEWED ("needs work") shape that run confirmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d9e1949 to
11c3fb8
Compare
|
Rebased: main moved in The old head's only reds were three Windows backend shards, each in a test this PR does not touch, and each one's fix has landed on main since the old base:
The patch is unchanged (range-diff |
Code change approver recommendation: A person should decideWhy: the decider estimates an 8% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed. This is a small, targeted fix in Tier: pending: being reviewed. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I reviewed head 11c3fb8 and traced how the activity stream is folded in _comment_rows. An UNAPPROVED activity now drops only the earlier review rows of the account that withdrew. Accounts are matched by account name or slug, and other reviewers' rows, comment rows and a later re-approval are kept. The provider test file passes on this head (49 tests), and all four cases of the new test fail against the main branch reader, so the test really pins the fix. I found no wrong behaviour, crash or data loss, so nothing blocks.
Problem / Motivation
Goal: A Bitbucket Server / Data Center reviewer who withdraws an approval stops reading as approved in the dashboard's pull-request read.
The live run on Bitbucket Data Center 9.4.26 reported in #21122 found it. A reviewer approved a pull request and then withdrew the approval. The instance's own
reviewersentry readsapproved: false, status: UNAPPROVED, but the reader still returned that reviewer's review row asAPPROVED. The raw/activitiesanswer, newest first, was[UNAPPROVED, UPDATED, APPROVED, OPENED].Why it matters
Anything that reads a Bitbucket Server pull request through the dashboard's
/api/source/pull-requestpayload (an app, an agent) gets a verdict the reviewer has taken back, and the Changes panel's Reviews tab counts it. That can make an unapproved change look approved.Not a goal
UNKNOWNbuild state (items 2-4 of the live run). They are things the reader does not read yet, not wrong answers.reviewerslist, or adding a new review state value.What changed (motivation → approach → change)
A withdrawn approval drops out of the review rows, so the payload agrees with the instance.
_comment_rowsindashboard/source_providers/bitbucket_server.pyturns the activity stream into rows, oldest first. It mapsAPPROVEDandREVIEWEDand skippedUNAPPROVED, so the earlierAPPROVEDrow stayed.UNAPPROVEDactivity drops that reviewer's earlier review rows, because after a withdrawal the instance reads the reviewer as having no verdict. A later re-approval adds its own row; other reviewers and all comment rows are untouched.user.name, elseuser.slug), not the display name, because two accounts can share a display name.Backwards compatibility
Compatible: the payload shape and the set of state values are unchanged; only a review row the instance itself has withdrawn is left out.
Reader: website/src/components/PullRequestPanel.tsx:reviews tab -- entry: chat -- its count is
source.comments.length, so a withdrawn approval stops adding to it; test_a_withdrawn_approval_no_longer_reads_as_approvedReader: website/src/components/CommentThreads.tsx:groupThreads -- entry: chat -- already skips review rows with no body, and Bitbucket Server review rows have none, so the list renders the same
Reader: website/src/app-sdk/PullRequestPanel.tsx -- entry: app -- reads the same
/api/source/pull-requestpayload; the other rows keep their id, kind and state (test asserts every row)Reader: src/kiro_crew/apps/builtins/auto_improvement/backend/pr_checks.py:_count_unresolved -- entry: app -- counts only
resolvablerows, and review rows areresolvable: FalseTests
test_a_withdrawn_approval_no_longer_reads_as_approvedintest/test_source_providers_bitbucket_server.pyserves an activity stream through the real/api/source/pull-requesthandler and asserts every row's id, kind and state:live: the four rows of the live run as posted (only dates added): no review row is left.withdrawn: the same, plus an added "needs work" by another account with the same display name, which still readsCHANGES_REQUESTED.re-approved: a new approval after the withdrawal yields thatAPPROVEDrow.needs-work-withdrawn: a reviewer's "needs work" is dropped by theirUNAPPROVED, and their comment row stays.-n0and 10 times at-n 4 --dist loadgroup --max-worker-restart=2beside the Gerrit and Jira provider tests, all green; the whole file in a shuffled order (seed 30892, 49 ids) green.Proof: PROVEN test/test_source_providers_bitbucket_server.py::test_a_withdrawn_approval_no_longer_reads_as_approved[live], test/test_source_providers_bitbucket_server.py::test_a_withdrawn_approval_no_longer_reads_as_approved[withdrawn], test/test_source_providers_bitbucket_server.py::test_a_withdrawn_approval_no_longer_reads_as_approved[re-approved], test/test_source_providers_bitbucket_server.py::test_a_withdrawn_approval_no_longer_reads_as_approved[needs-work-withdrawn] (head 79967bf)
Manual verification
Run on Linux (Ubuntu 24.04, x86_64). No licensed Bitbucket Server / Data Center instance is available there, so the real gateway handler
/api/source/pull-requestwas driven on an aiohttp app, with the instance answered by the test file's_Instancestub serving the reporter's four/activitiesrows verbatim (ids, accounts, display names).Before the fix (base reader), the payload's
comments:After the fix:
Nearby happy path after the fix: the existing fixture's approval by
rev1(id 903) still readsAPPROVED, and inline thread 11 (ids 11 and 12) is unchanged. The whole test file passes (49 tests).On a live Bitbucket Data Center 9.4.26 instance, the reporter ran the reader at this PR's merge base and at its head (comment): an approval withdrawn by
DELETE /approveor byPUT participantswith statusUNAPPROVEDwent from oneAPPROVEDrow to no review row; approve, withdraw, approve again gave oneAPPROVEDrow; another reviewer's kept approval still readAPPROVED.Real-machine verification
Machine: EC2 m7i.2xlarge, Ubuntu 24.04.5 x86_64, 8 vCPU / 32 GiB; about 2 hours, about $0.81 on demand
Before (main c22557c):
python3 -m pytest -n0 -s -q -p no:cacheprovider test/test_zz_repro_21122.py(a temporary driver, not committed, that serves the live run's four/activitiesrows to the real/api/source/pull-requesthandler) ->comments = [{"id": "322", "kind": "review", "author": "EE Operator", "state": "APPROVED"}]After (head 79967bf): the same command ->
comments = [], and the existing fixture's approval (id 903) still readsAPPROVED;test/test_source_providers_bitbucket_server.py49 passedCleanup: instance terminated (
describe-instancesfor it prints[],describe-volumesfor it prints[]); reached over SSM, no key pair; its security group has no ingress rules and is not one made for this PRRelated Issues
Closes #21122
Sibling sweep
Swept: git grep -nE '"kind": "review"|_github_comment(item, "review")|approv' -- src/kiro_crew/dashboard/source_providers/
Sibling: src/kiro_crew/dashboard/source_providers/github.py -- not affected -- GitHub returns a dismissed review in place with state DISMISSED
Sibling: src/kiro_crew/dashboard/source_providers/gerrit.py -- not affected -- it reads the current Code-Review votes, so a removed vote is 0 and skipped
Sibling: src/kiro_crew/dashboard/source_providers/gitlab.py -- not affected -- it emits no review verdict rows
Pattern harvest
Not generalizable: the defect is one provider's event vocabulary missing its withdrawal event; the other readers build verdicts from a current-state snapshot.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits