Skip to content

πŸ› fix(test): bypass the shared PR-detail cache in repo-item decision tests - #15462

Merged
clubanderson merged 1 commit into
hivecommons:v5from
odttlnt:fix/repo-item-merge-guard-flake-15461
Oct 29, 2026
Merged

clubanderson merged 1 commit into
hivecommons:v5from
odttlnt:fix/repo-item-merge-guard-flake-15461

Conversation

@odttlnt

@odttlnt odttlnt commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Why

TestRepoItemDecisionMergeDecisionsGuard failed on v5 in run 40932791908 (jobs dashboard 4/4 and dashboard shuffle 1/3; the gotestsum rerun passed). The log shows:

api_repo_item_decision_test.go:630: merge-now on one's own PR: code=200 ...
api_repo_item_decision_test.go:634: guards must stop before GitHub writes: merges=[map[merge_method:squash ...]]

The own-PR guard in handlePullRequestMergeDecision reads the author through GetPRAuthor, which first consults the process-global PR-detail cache (sharedPRDetailCache, keyed by repo+number, 30 min default TTL). Every decision test uses testorg/testrepo#8, so when another test in the same binary had already cached #8 (author hive[bot]), the cache answered instead of this test's mock. "someone" then was not the author and merge-now went through to GitHub. Which test ran first depends on test order and sharding, hence the flake (and why the shuffle shard hit it too).

What changed

newRepoItemDecisionServer sets a zero PR-detail TTL on its client (SetPRDetailTTLFunc), so every PR read goes to the mock. This is the same knob the pkg/github cache tests use. Test-only; no production code touched, so no changelog.d/ fragment (*_test.go is exempt).

Per AGENTS.md I did not run the suite locally; CI is the verdict.

Closes #15461

β€” hive: backend=bob model=premium

…em decision mock

TestRepoItemDecisionMergeDecisionsGuard failed intermittently: the
own-PR guard in handlePullRequestMergeDecision reads the PR author through
GetPRAuthor, which consults the process-global PR-detail cache keyed by
repo+number. A "testorg/testrepo" PR hivecommons#8 cached by an earlier test in the
same binary (hive[bot] author, 30 min TTL) answered instead of this
test's mock, so the "someone" caller was no longer the author and
merge-now went through to GitHub (code=200, one PUT /merge).

newRepoItemDecisionServer now sets a zero PR-detail TTL on its client so
every read goes to the mock. Test-only; no production change.

Hive-Run: hivecommons#15461
Hive-Plan: fix flaky test (isolate PR-detail cache in test mock)
Hive-Spec: ci-flake#TestRepoItemDecisionMergeDecisionsGuard
Signed-off-by: SACHIN NAIK <sachin.naik@ibm.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15307 πŸ› fix: refuse workflow-changing fork rebase follow-through same files src/pkg/dashboard/api_repo_item_decision_test.go

@hivecommons-hive hivecommons-hive 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.

Read this against the cache in the tree, not just the diff: SetPRDetailTTLFunc (src/pkg/github/client.go:1434) feeds effectivePRDetailTTL, and every read path GetPRAuthor/GetPRState take β€” cachedPRDetailAny β†’ getAny β†’ getLocked β€” misses unconditionally when ttl <= 0 (src/pkg/github/prdetailcache.go:89). The cache really is one process-global sharedPRDetailCache (prdetailcache.go:44), so the cross-test bleed the comment describes is real, and a zero TTL closes it for this client only. The one path that ignores TTL, getMergedBy, is reached from prclaims.go:1131, not from these handlers.

time is already imported in the test file. Looks correct to me; the failing check (Sign-off survives the squash: CANCELLED) is a runner cancellation, not this diff.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive 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.

Read the cache path this relies on, not just the diff. Looks correct to me.

  • src/pkg/github/client.go:1449-1455 β€” effectivePRDetailTTL returns the injected TTL whenever it is >= 0, so 0 is honoured rather than falling back to the config default.
  • src/pkg/github/prdetailcache.go:89 β€” getLocked misses outright when ttl <= 0, and GetPRAuthor (client.go:2894) / GetPRState go through cachedPRDetailAny β†’ getLocked, so a stale #8 cached by another test in the same process can no longer answer here. getMergedBy (prdetailcache.go:68) ignores the TTL, but nothing on the repo-item decision path reads it.
  • Same SetPRDetailTTLFunc seam the package's own tests already use (close_on_merge_test.go:164, prdetailcache_test.go:121), just with 0 instead of time.Hour.

Test-only, five lines, no behaviour change outside the test.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 080-awaiting-merge-admission β†’ 060-reviewed: contributor-lane:claim-tier-untrusted

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Ready for a human merge: verdict approved @f6e8fe0, 58/58 checks green, DCO yes, soak 30m0s elapsed. Blocked only by role/contributor (below require_tiers).

The hive never approves on your behalf: /lgtm /approve (or merge) if you accept it.

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

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci-flake: github.com/hivecommons/hive/pkg/dashboard.TestRepoItemDecisionMergeDecisionsGuard

2 participants