Skip to content

🐛 fix(automerge): expire 404'd closing-link targets instead of caching them forever - #15139

Merged
hivecommons-hive[bot] merged 2 commits into
v6from
scanner/fix-15120
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v6from
scanner/fix-15120

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

A closing-keyword target that 404'd was cached as not-a-PR for the process lifetime, so a transient 404 or a number later allocated to a PR bypassed the closing-keyword gate. Missing targets now expire after 10 minutes; existing non-PR issues stay cached.

Closes #15120

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

…g them forever

A closing-keyword target that returned 404/410 was cached as not-a-PR for the process lifetime. A transient or masked 404, or a number later allocated to a pull request, then slipped past the closing-keyword gate. Missing targets are now trusted for 10 minutes; existing non-PR issues stay cached.

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 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 kellyaa 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

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

No conflicting open PRs or same-file overlaps were found.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The production change is correct; the new test is why test (rest 4/4) is red, and it fails deterministically, not flakily.

Finding (test defect, medium): src/pkg/github/automerge/automerge_closing_link_test.go:342-355 — TestClosingKeywordMissingTargetExpires calls numberIsOpenPullRequest for acme/widget#1036 without ever seeding that key in the front. The front only counts reads for keys it owns: automerge_linked_issue_test.go:181-185 does issue, ok := f.issues[key]; if ok { f.reads[key]++ } and otherwise proxies to the backend. So the first two reads produce a backend 404 (which the engine caches correctly via automerge_closing_link.go:164-166) but front.readsOf(target) stays 0, and line 355 fails with reads within TTL = 0, want 1 — exactly what CI job 123138545532 shows on every run.

Fix is one line before the first read:

front.set(target, linkedIssue{status: http.StatusNotFound})

The front then serves the 404 itself (automerge_linked_issue_test.go:188-191) and counts it, so the assertions 1 (within TTL) and 2 (after set(..., pr: true) past the TTL) hold as written. http is already imported in that test file via the other cases.

What I verified about the engine side: noteClosingTarget (automerge_closing_link.go:135-151) stores a zero expiry for existing non-PR issues and now+10m for nil, and the cache check at :156-158 treats zero as permanent and a set expiry as valid only while clock().Before(expires). The cache-reset at closingLinkCacheMax and the field type change in automerge_sweep.go:311 are consistent. Looks right to me once the test is fixed.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The production change is correct; the new test fails deterministically and will keep test (rest 4/4) and coverage red until it is fixed.

Why the test fails (automerge_closing_link_test.go:355: reads within TTL = 0, want 1, three times in the CI log for this head):

linkedIssueFront only counts a read when the key is already in f.issues — automerge_linked_issue_test.go:181-186:

issue, ok := f.issues[key]
if ok {
    f.reads[key]++
}

Unknown keys fall through to proxy.ServeHTTP. TestClosingKeywordMissingTargetExpires never sets acme/widget#1036 before the first two numberIsOpenPullRequest calls, so the 404 comes from the backend fixture and is never counted. The fix is one line before the first call:

front.set(target, linkedIssue{status: http.StatusNotFound})

Then the later front.set(target, linkedIssue{state: "open", pr: true}) flips it to a PR and the want 2 assertion holds. (http is already imported in that file.)

What I verified in the production code:

  • noteClosingTarget (automerge_closing_link.go:134-150) stores a zero time.Time for an existing non-PR issue and clock()+10m for a nil (404/410) issue, and numberIsOpenPullRequest (:157-161) treats zero as "forever" and otherwise re-reads once clock() reaches the expiry. That is exactly the stated behaviour: existing issues cached for the process, missing numbers trusted for 10 minutes.
  • The 404 path at :165-168 is the only writer of a nil entry, and c.clock() (automerge_held_runs.go:254) is the existing seam the test overrides via c.now, so the test's clock manipulation drives the real code path.
  • The closingLinkCacheMax reset still applies to the retyped map.

Once the test is fixed this looks correct to me.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
linkedIssueFront only counts reads for registered numbers; an unregistered one falls through to the backend uncounted, so readsOf stayed 0. The test now registers acme/widget#1036 as a 404 first.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-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 Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 3033a79 into v6 Oct 29, 2026
81 of 83 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15120 branch October 29, 2026 06:15
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#15139cf5adb1` sha256:5ac431a6ff1eb8af831758066cbb10c39be2e0e6ccc71edf55b345a72f96531a — download from the dashboard or `hivectl review evidence #15139`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/stalled In its current stage longer than expected labels Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review backlog (security): 404'd closing-keyword target cached as not-a-PR for the process lifetime

0 participants