From ec8624fd564133ba9a412ca515ec0c000bb30c1d Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:20:05 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20fix(github):=20retire=20merg?= =?UTF-8?q?e-queue-required=20alerts=20on=20positive=20evidence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-merge-queue-required-retire.md | 1 + src/docs/hive-merge.md | 5 +- src/pkg/github/merge_failure_alert.go | 6 ++ .../merge_failure_alert_revalidate_test.go | 61 +++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-merge-queue-required-retire.md diff --git a/changelog.d/fixed-merge-queue-required-retire.md b/changelog.d/fixed-merge-queue-required-retire.md new file mode 100644 index 0000000000..2e29c308aa --- /dev/null +++ b/changelog.d/fixed-merge-queue-required-retire.md @@ -0,0 +1 @@ +A merge-queue-required operator alert now clears on its own once the base branch's rules no longer include a merge queue, instead of lingering until the PR closes. diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index cfa5154958..ac07242319 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -141,7 +141,10 @@ five minutes (`mergeAlertRevalidateInterval` in `src/pkg/github/merge_failure_alert.go`): an alert is dropped once the blocked PR is no longer open, and a fork-approval alert is dropped as soon as the PR head has no workflow runs still `action_required` — i.e. the operator approved -them or relaxed the repo/org setting. API errors keep the alert in place. +them or relaxed the repo/org setting. A merge-queue-required alert is dropped +once the base branch's active rules, read successfully, no longer include a +merge queue; otherwise it stays until the PR is closed or merged. API errors +keep the alert in place. **Unprotected base branches are allowed.** The watcher no longer makes a separate branch-protection lookup and no longer refuses solely because the base diff --git a/src/pkg/github/merge_failure_alert.go b/src/pkg/github/merge_failure_alert.go index 700415bfa6..3ed5fd03b1 100644 --- a/src/pkg/github/merge_failure_alert.go +++ b/src/pkg/github/merge_failure_alert.go @@ -188,6 +188,12 @@ func (c *Client) revalidateMergeFailureAlerts(ctx context.Context, nowFn func() }) resolved = rerr == nil && runs != nil && runs.GetTotalCount() == 0 } + if !resolved && w.entry.key == "merge-queue-required" && pr.GetBase().GetRef() != "" { + // Positive evidence the rule is gone: the base branch's active + // rules were read successfully and none is a merge queue. + rules, _, rerr := c.client.Repositories.GetRulesForBranch(ctx, owner, name, pr.GetBase().GetRef(), nil) + resolved = rerr == nil && rules != nil && len(rules.MergeQueue) == 0 + } if !resolved { continue } diff --git a/src/pkg/github/merge_failure_alert_revalidate_test.go b/src/pkg/github/merge_failure_alert_revalidate_test.go index 85f28771d1..29ef5ec8c8 100644 --- a/src/pkg/github/merge_failure_alert_revalidate_test.go +++ b/src/pkg/github/merge_failure_alert_revalidate_test.go @@ -171,3 +171,64 @@ func TestRevalidateMergeFailureAlerts_AppPermissionClearsOnSuccessfulRead(t *tes t.Fatalf("expected app-permission alert cleared, got %v", sink.clears) } } + +const mergeQueueRequiredErr = "merging PR o/r#7 (squash): PUT https://api.github.test/repos/o/r/pulls/7/merge: 405 Repository rule violations found\n\nChanges must be made through the merge queue" + +// A merge-queue-required alert retires while the PR is still open once the +// base branch's rules no longer include a merge queue. +func TestRevalidateMergeFailureAlerts_MergeQueueRequiredClearsWhenRuleRemoved(t *testing.T) { + var rulesStatus atomic.Int32 + rulesStatus.Store(http.StatusOK) + var queued atomic.Bool + queued.Store(true) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + switch { + case r.Method == http.MethodGet && strings.Contains(r.URL.Path, "/pulls/"): + _, _ = io.WriteString(w, `{"number":7,"state":"open","head":{"sha":"abc"},"base":{"ref":"main"}}`) + case r.Method == http.MethodGet && strings.HasSuffix(r.URL.Path, "/rules/branches/main"): + if code := int(rulesStatus.Load()); code != http.StatusOK { + w.WriteHeader(code) + return + } + if queued.Load() { + _, _ = io.WriteString(w, `[{"type":"merge_queue","parameters":{}}]`) + return + } + _, _ = io.WriteString(w, `[{"type":"deletion"}]`) + default: + w.WriteHeader(http.StatusInternalServerError) + } + })) + defer srv.Close() + + c := testMergeClient(t, srv.URL) + sink := &recordingMergeAlertSink{} + c.SetMergeFailureAlertSink(sink) + c.raiseMergeFailureAlert("o/r", 7, mergeQueueRequiredErr) + if len(sink.adds) != 1 { + t.Fatalf("expected 1 alert, got %d", len(sink.adds)) + } + + now := time.Date(2026, 11, 2, 12, 0, 0, 0, time.UTC) + nowFn := func() time.Time { return now } + c.revalidateMergeFailureAlerts(context.Background(), nowFn) + if len(sink.clears) != 0 { + t.Fatalf("alert cleared while merge queue rule still applies: %v", sink.clears) + } + + queued.Store(false) + rulesStatus.Store(http.StatusBadGateway) + now = now.Add(mergeAlertRevalidateInterval) + c.revalidateMergeFailureAlerts(context.Background(), nowFn) + if len(sink.clears) != 0 { + t.Fatalf("alert cleared on rules read error: %v", sink.clears) + } + + rulesStatus.Store(http.StatusOK) + now = now.Add(mergeAlertRevalidateInterval) + c.revalidateMergeFailureAlerts(context.Background(), nowFn) + if len(sink.clears) != 1 || sink.clears[0] != sink.adds[0].id { + t.Fatalf("expected merge-queue-required alert cleared, got %v", sink.clears) + } +} From cf940041cfc2d7028c8bac20eb83469ce9e3851c Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 01:20:54 +0000 Subject: [PATCH 2/3] changelog: fragment for #16350 Generated by changelog-fragment-guard from the PR title (#5675). Edit the wording freely, or replace this file with the no-changelog label if the change is not user-visible. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16350.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/fixed-16350.md diff --git a/changelog.d/fixed-16350.md b/changelog.d/fixed-16350.md new file mode 100644 index 0000000000..d94842c5e6 --- /dev/null +++ b/changelog.d/fixed-16350.md @@ -0,0 +1 @@ +- fix(github): retire merge-queue-required alerts on positive evidence (#16350) From dfa41ae2f75cc1af26dd194bb560772bb702b4fb Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 20:38:02 -0500 Subject: [PATCH 3/3] chore(changelog): fold the prose fragment into the bulleted one changelog-fragment-guard requires a '- ' entry bullet; the second fragment was prose and duplicated fixed-16350.md. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-16350.md | 2 +- changelog.d/fixed-merge-queue-required-retire.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 changelog.d/fixed-merge-queue-required-retire.md diff --git a/changelog.d/fixed-16350.md b/changelog.d/fixed-16350.md index d94842c5e6..0e1ea7b666 100644 --- a/changelog.d/fixed-16350.md +++ b/changelog.d/fixed-16350.md @@ -1 +1 @@ -- fix(github): retire merge-queue-required alerts on positive evidence (#16350) +- fix(github): a merge-queue-required operator alert now clears on its own once the base branch's rules no longer include a merge queue, instead of lingering until the PR closes (#16350) diff --git a/changelog.d/fixed-merge-queue-required-retire.md b/changelog.d/fixed-merge-queue-required-retire.md deleted file mode 100644 index 2e29c308aa..0000000000 --- a/changelog.d/fixed-merge-queue-required-retire.md +++ /dev/null @@ -1 +0,0 @@ -A merge-queue-required operator alert now clears on its own once the base branch's rules no longer include a merge queue, instead of lingering until the PR closes.