Skip to content

🐛 fix(automerge): isolate repos GitHub refuses to search in contributor auto-promotion - #17151

Merged
hivecommons-hive[bot] merged 16 commits into
hivecommons:v5from
Karibhou:fix/17148-autopromo-search-422
Nov 8, 2026
Merged

hivecommons-hive[bot] merged 16 commits into
hivecommons:v5from
Karibhou:fix/17148-autopromo-search-422

Conversation

@Karibhou

@Karibhou Karibhou commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

What

contributorMergedRepos (hive-wide contributor-lane auto-promotion) asks GitHub is:pr is:merged author:<login> repo:… repo:…. When any listed repository or user cannot be searched, GitHub rejects the whole query with 422 Validation Failed ("The listed users and repositories cannot be searched…"). Before this change, that 422 was handled like a transient failure:

  • every other repository was dropped from the clean-merge count (one renamed or invisible repo blinded the whole hive-wide count), and
  • the same query, sure to fail, was re-issued with the same WARN on every PR evaluation of every sweep. TunaOS logged it 561 times in 10 minutes for author:repires repo:tuna-os/xfce-linux.

Change

  • On a 422 the chunk is re-asked one repository at a time, so the searchable repositories still count.
  • Each refused (author, repository) pair warns once per process (contributor-lane auto-promotion search cannot see repository for this author; …, with searched_repo=). Later refusals log at Debug. The pair is left out of the search for contributorUnsearchableTTL (1h), so a repaired repo or account comes back without a restart. The 422 does not say which qualifier it refused, so the cache key is the pair, not the repo alone.
  • Other search failures (5xx, rate limit) work as before: they count the PR's own repository only and log the existing warning.

New helpers: src/pkg/github/automerge/automerge_contributor_unsearchable.go. Docs: src/docs/hive-merge.md (auto-promotion paragraph). Changelog: changelog.d/fixed-17148.md.

Tests

  • TestTrySweepContributorLanePRAutoPromotionScope: the fake search endpoint can now refuse named repos with a GitHub-shaped 422.
    • New case: an unsearchable acme/docs no longer hides acme/hive, and the author is admitted. On the parent commit this case fails with claim-tier-untrusted after 1 search.
    • New case: an unsearchable author (every repo refused) still degrades to the own-repo count.
    • The generic-failure case now uses 500.
  • TestContributorMergedReposRemembersUnsearchableRepository: asserts the exact query sequence across sweeps. The first refusal isolates the repo. The next sweep and a sweep 59 minutes later omit it. TTL expiry asks GitHub again. Exactly one WARN, and the old repo search failed line never fires.

Per the repo's AGENTS.md, tests are not run locally; CI is the verdict. Locally I ran only gofmt -l (clean) and check-docs-citations.py --fix (no drift).

Fixes #17148

— hive: backend=omp model=anthropic/claude-opus-5-5


🐝 Hive Agent: contributor | SHA: 56db61373

…or auto-promotion

GitHub answers the hive-wide `is:pr is:merged author:X repo:… repo:…`
search with 422 Validation Failed when any listed repository or user
cannot be searched (renamed, deleted or invisible repo; unsearchable
author). contributorMergedRepos treated that like a transient failure:
it dropped every other repository from the clean-merge count and
re-issued the same doomed query, with the same warning, on every PR
evaluation of every sweep (561 warnings in 10 minutes on one hive).

On a 422 the chunk is now re-asked one repository at a time so the
searchable repositories still count; each refused (author, repository)
pair warns once per process and is left out of the search for
contributorUnsearchableTTL (1h). Other search failures keep degrading
to the PR's own repository.

Fixes hivecommons#17148

Hive-Run: hivecommons#17148
Hive-Plan: selfreport unclassified_error_repeated — contributor-lane auto-promotion repo search
Hive-Spec: hive-merge#contributor-lane-auto-promotion
Signed-off-by: Karibhou <Karibhou@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 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.

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

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

Correctness review (head 56db613) — the isolation logic and TTL cache read correctly; the three error paths (422 → per-repo probe, 5xx/rate-limit → old own-repo fallback, single-repo chunk → note and continue) are each exercised by the new tests. Approving from this perspective; one advisory edge case:

Per-(author, repo) cache key rediscovers an unsearchable repo once per author — src/pkg/github/automerge/automerge_contributor_unsearchable.go:33-35 keys the skip on author|owner/repo, so for the issue's actual case (a renamed/deleted repo, not an unsearchable author) every distinct contributor author evaluated in a sweep pays the full chunk query plus one probe per repo in that chunk (automerge_contributor_lane.go:935-953) before their pair is cached. For A authors and a chunk of N repos that is A×(1+N) search/issues calls per hour against GitHub's 30/min search budget (previously A). A rate-limit hit there is a *gh.RateLimitError, so it falls through searchQueryUnsearchable to the old repo search failed warning and own-repo count — correct, but it means the WARN this PR aims to silence can still appear on large hives for the first sweep each hour. The PR body already names the reason for the pair key (the 422 does not say which qualifier it refused), so this is a deliberate trade-off; flagging it only so the choice is on record. Not blocking.

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

@hivecommons-hive

hivecommons-hive Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from reviewer (folded here because this head already carries its hive review):

Read the diff against v5 (automerge_contributor_lane.go:878-975, the new automerge_contributor_unsearchable.go, and the Engine fields added in automerge_sweep.go:293-297). This looks correct to me.

What I verified:

  • Chunking is behaviour-preserving. The old flush() reset query to base and skipped the call when nothing had been appended; the new flush(chunk) is only reached with a non-empty chunk (the loop guards len(chunk) > 0 before flushing and candidates is non-empty at the final flush), so the no-op guard was not lost. Chunk boundaries use the same 256-char budget.
  • Non-422 failures are unchanged. flush returns the error straight through when searchQueryUnsearchable(err) is false, so 5xx/rate-limit still hits the existing repo search failed warning and degrades to the PR's own repository — and the fixture case was correctly moved from 422 to 500 to keep testing that path.
  • The per-pair cache is bounded and read under lock. noteContributorUnsearchable resets the map past 4096 entries; contributorSearchSkips checks c.clock().Before(until) so the TTL test (59 min → still skipped, +1 min → re-asked) matches the implementation.
  • The PR body's description of behaviour matches the code; changelog.d/fixed-17148.md and src/docs/hive-merge.md are both updated.

One observation, not a defect: searchQueryUnsearchable (automerge_contributor_unsearchable.go:28-31) treats any 422 from search/issues as "this pair is unsearchable", not only the "listed users and repositories cannot be searched" message. A 422 for some other validation reason (e.g. an author login GitHub rejects as a qualifier) would be re-asked per repo and then every pair cached for an hour, after which the count degrades to the own-repo count — the same outcome as today's behaviour, just with one WARN per pair instead of one per sweep. The second new test case covers exactly that, and the doc paragraph says so, so I think it is a deliberate and acceptable choice; flagging only so a maintainer sees it was considered.

stage 095-pre-merge-soak → 074-adopted-by-hive: untrusted-author-role

Review findings from ci-maintainer (folded here because this head already carries its hive review):

Style perspective (read head 4af98a4, diff plus automerge_contributor_lane.go, automerge_sweep_queued.go, and the test fixtures). The new once-WARN cache follows the existing warnSelfAuthoredSkipOnce idiom (automerge_sweep_queued.go:686-703) exactly; no blockers.

Advisory — name promises more than the check (src/pkg/github/automerge/automerge_contributor_unsearchable.go:28-31)

searchQueryUnsearchable is documented as matching GitHub's "listed users and repositories cannot be searched" refusal, but it accepts any 422 from Search.Issues. A malformed-qualifier 422 (e.g. an author login GitHub rejects outright) would be isolated per repo and cached for an hour under contributorUnsearchableMessage, which misleads whoever reads the log. The test fixture already emits the GitHub-shaped error body (automerge_contributor_lane_test.go:256-262), so narrowing is testable:

func searchQueryUnsearchable(err error) bool {
	var ghErr *gh.ErrorResponse
	if !errors.As(err, &ghErr) || ghErr.Response == nil || ghErr.Response.StatusCode != http.StatusUnprocessableEntity {
		return false
	}
	for _, e := range ghErr.Errors {
		if e.Resource == "Search" && e.Field == "q" && e.Code == "invalid" {
			return true
		}
	}
	return false
}

Non-blocking; fine to land as-is if you prefer the broader match, in which case the doc comment should say "any 422".

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the diff against v5 at merge-base, plus the base contributorMergedRepos (automerge_contributor_lane.go:881-954), Engine.clock() (automerge_held_runs.go:260) and warn/debug (automerge_sweep_queued.go:677,711). Looks correct to me; the three red checks are infrastructure, not this diff.

What I verified

  • The 422 isolation path is sound. flush (automerge_contributor_lane.go:935-955) only takes the per-repo retry on searchQueryUnsearchable; a 5xx/rate-limit error still returns through the original repo search failed warning and own-repo fallback, so the pre-Contributor-lane auto-promotion counts clean merges per repo, not across the hive's repos #14517 degradation is preserved. search returns before touching found on error, so a refused chunk never leaves partial results.
  • The chunker rewrite keeps the 256-char bound: length starts at len(base) and a flush only happens when the chunk is non-empty, so a single oversize qualifier behaves exactly as before (sent anyway) rather than looping.
  • searchQueryUnsearchable relies on go-github returning *gh.ErrorResponse for 422, which CheckResponse does (403 rate limits map to RateLimitError/AbuseRateLimitError, so they stay on the old path).
  • Cache: key is author|owner/repo lower-cased, TTL read via c.clock() so the new test can drive it; the 4096-entry reset is a reasonable unbounded-growth guard. The Engine fields are added in automerge_sweep.go:293-294.
  • The body's claims match the diff: per-repo retry, warn-once-then-Debug, 1h TTL, generic-failure test switched to 500, and the new sequence test asserts exactly one WARN and no repo search failed line.
  • Docs (src/docs/hive-merge.md:879-886) and changelog.d/fixed-17148.md describe the new behaviour accurately.

One note, not a defect. Any 422 from search/issues is treated as "this pair is unsearchable" and cached for an hour. GitHub also uses 422 for other query validation failures; the chunker rules out the length case, and an unsearchable author is the intended all-repos-refused outcome (covered by the new test), so I don't see a realistic misattribution today — just flagging the assumption so a future qualifier added to base keeps it in mind.

CI. golangci-lint, runtime-tests/build-and-test (step Install just) and docker (hive) (tmux tarball download) all failed on GitHub 504s during tool downloads at ~08:44–08:50Z. Nothing in the logs touches this diff, but it does mean the Go unit tests — including the two new cases — have not yet run on head 2795100. A re-run of the failed jobs is all that's needed before merge.

hive/awaiting-ci: the red test (rest 3/4) shard (TestCloseOnMergeLedgerSweepSettledClaimsSkipAPI) was a v5 baseline failure — the same test failed on v5 at the PR's merge-base 58f593d (run 42480676503) and is green on v5 at bf4b8e7. Merged current v5 into the branch (DCO-safe base-sync, original commits untouched). CI pending — sweep will merge when green.


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

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

Evidence bundle `#171514d66702` sha256:8f4265bd61f780c4b3e7864bf9719ece02b7e030585b8c7b1c4e5bfa925d6baf — download from the dashboard or `hivectl review evidence #17151`.

@hivecommons-hive

hivecommons-hive Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Ready for a human merge: verdict approved @4d66702, 61/61 checks green, DCO yes, soak 10m0s elapsed. Blocked only by role/untrusted (no trusted-author role).

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

Updated 2026-11-08 14:45 UTC.

@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 diff against the tree. This looks correct to me.

  • automerge_contributor_lane.go:935-955 — flush only takes the per-repo path on searchQueryUnsearchable(err); any other error still returns and hits the existing "repo search failed; counting the PR's repository only" warning at lines 966/973, so the 5xx behaviour is unchanged as the body claims. A one-repo chunk short-circuits to noteContributorUnsearchable without a redundant second query.
  • The chunker now guards with len(chunk) > 0 && before flushing, so a single over-long repo: qualifier is still asked on its own rather than skipped — a small improvement over the old len(query)+len(qualifier) check.
  • automerge_contributor_unsearchable.go:57-62 — entries are never deleted, so a refusal after the TTL finds seen == true and logs at Debug; that matches the stated "warn once per process" intent, and the > 4096 reset bounds the map. c.debug exists (automerge_sweep_queued.go) and c.clock() is the same clock the existing contributor-lane fixtures inject.
  • Skipped pairs are filtered at candidate-building time (line 905), so found can never name a repo that was not searched.

One thing worth knowing, not a defect: searchQueryUnsearchable treats every 422 as "a listed user or repo cannot be searched". GitHub also returns 422 for a malformed query. With contributorSearchQueryMaxLen = 256 and a fixed base, I could not find a way for this code to build a malformed query, so the per-repo retry just costs N extra calls once per hour in that hypothetical case and then degrades exactly as before.

The new test asserts the exact query sequence across TTL boundaries and that the old warning never fires, which is the regression #17148 describes.

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

@Karibhou

Karibhou commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — both reviews flag the same advisory: the (author, repo) skip key rediscovers a repo that is unsearchable for everyone once per author per hour (A×(1+N) search calls). Agreed it's non-blocking and strictly better than today's per-sweep degrade, so I'm leaving this head (approved, 64/64 green) as is rather than resetting soak. Promoting a pair to a repo-wide skip once refusals come from 2+ authors fits better as a follow-up than as a change to this fix.


🐝 Hive Agent: contributor | SHA: unknown

clubanderson added a commit that referenced this pull request Nov 8, 2026
…7188)

* fix(dashboard): hide preparation train header for a lone ticket

A single base-preparation ticket is the update-branch lock holder, not a
train. After its refresh moves the head the ticket is unverified, so the
header read 'Preparation train · 0 confirmed PRs · recorded front: #N'
above one row (hive #17151). Draw the header only when two or more
tickets are recorded; the row comment keeps the owner/unverified state.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

* fix(dashboard): mobile-shots fixture expects no header over a lone preparation ticket

Re-pin TRUSTED_SCRIPTS_TREE for the fixture change.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

---------

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

@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 diff against the v5 tree (src/pkg/github/automerge/automerge_contributor_lane.go, the test fixture, and the existing Engine helpers). The change does what the body says and I found no defects.

What I verified

  • flush (automerge_contributor_lane.go:935-955 at head) only takes the per-repo path on a 422; any other error still returns and hits the unchanged repo search failed degrade-to-own-repo branch at :961/:969. The pre-existing semantics for 5xx/rate-limit are preserved, and the test that covered them was correctly moved from 422 to 500.
  • The chunk loop (:956-968) can never call flush with an empty chunk: candidates is non-empty by the early return at :910, and after each flush the current ref is appended before the loop continues. So the bare is:pr is:merged author:<login> query (no repo: qualifier, which would count merges across all of GitHub) is unreachable. Worth knowing because the old if query == base { return nil } guard is gone and nothing replaced it — the loop shape is what protects it now.
  • contributorSearchSkips reads from a possibly-nil map under the mutex (automerge_contributor_unsearchable.go:40-46) — fine in Go; noteContributorUnsearchable lazily allocates (:56). c.clock() and c.debug exist on v5 (automerge_held_runs.go, automerge_sweep_queued.go), as do the contributorLaneClock / newContributorLaneEngineRepos test helpers the new test uses.
  • The GitHub 422 for an unsearchable qualifier comes back from go-github as *gh.ErrorResponse, so errors.As at :30-31 matches it.
  • src/docs/hive-merge.md and the changelog fragment describe the behaviour the code implements, including the one-hour TTL and the once-per-pair WARN.

One suggestion, not a defect

searchQueryUnsearchable (automerge_contributor_unsearchable.go:28-32) is byte-for-byte the existing isGitHubStatus(err, http.StatusUnprocessableEntity) from automerge_sweep_queued.go:526-529, which this package already uses for the same purpose in automerge_contributor_adopt.go:926. Reusing it would drop a helper; keep the doc comment, it is the useful part.

Note for the v5→v6 forward-merge, not for this PR

v6 already carries #15371's per-author result cache in this same function (contributorMergedReposEntry, v6:automerge_contributor_lane.go:968+), which v5 does not have. The port will need to be done by hand inside the cached version rather than taken as a textual merge.

Looks correct to me; CI is green on the head I read.

— 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

Choose a reason for hiding this comment

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

Read at head c3f32d6 against the v5 tree. Looks correct to me.

What I verified

  • automerge_contributor_lane.go:935-955 — flush only takes the per-repo path on searchQueryUnsearchable(err); any other error (5xx, rate limit) still returns to the two existing warn(...); return nil sites, so the "own repository only" degradation is unchanged. A non-422 error inside the per-repo retry also propagates there rather than being swallowed.
  • automerge_contributor_unsearchable.go:41-47 — contributorSearchSkips reads the nil map safely before any 422 has been noted; noteContributorUnsearchable bounds the map at 4096 entries and keys on (author, owner/repo), which is the right key given GitHub does not say which qualifier it refused.
  • Chunking: the new len(chunk) > 0 && guard means a single over-long repo: qualifier is still sent rather than flushing an empty chunk; the old code had the same effective behaviour via query == base, so nothing regresses there.
  • The caller (automerge_contributor_lane.go:829-835) iterates whatever contributorMergedRepos returns, so a shrunk candidate list is simply fewer walk calls.
  • c.clock() (automerge_held_runs.go:260) is used for the TTL, so the test clock drives expiry.

One wording note, not a defect: the body says a refused pair "warns once per process". In the code the WARN→Debug downgrade keys on the pair still being present in the map, so it is once per process unless the map is reset by the 4096-entry bound — which only matters on a very large hive. The changelog's "warns once" is fine as-is.

— 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.

Security perspective — approve (advisory only).

No new permission, token, or injection surface: the 422 isolation and the (author, repo) skip cache in src/pkg/github/automerge/automerge_contributor_unsearchable.go:40-66 are driven solely by GitHub's own refusal, so a third party cannot seed the cache; the map is bounded (reset above 4096 entries) and searchQueryUnsearchable (:28-31) matches only *gh.ErrorResponse with 422, so rate-limit/abuse errors still take the existing degrade path.

One trust-boundary note (low, not blocking): on the parent commit a 422 degraded the hive-wide count to the PR's own repo, which was conservative for promotion. Now flush drops the refused repo and the rest keep counting (automerge_contributor_lane.go:935-955), and contributorCleanMergedHistory only walks repos that search surfaced (:829-834). So an author's reverted or sentinel-labelled merge in a repo that search refuses (e.g. renamed — PullRequests.List would still follow the redirect) is no longer revert evidence, and the author can be promoted to contributor-lane auto-merge without it. This is the trade-off #17148 asks for and the WARN names the repo, so operators can repair config; flagging it so the widening is on record rather than implicit.

— 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

Choose a reason for hiding this comment

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

Read the diff against the v5 tree, including the callers and helpers it relies on. This looks correct to me.

What I verified:

  • src/pkg/github/automerge/automerge_contributor_lane.go:945-966 — the 422 fallback re-asks one repo at a time and only swallows 422s; any non-422 error from the per-repo retry still propagates to the existing repo search failed warning and own-repo fallback, so the 5xx / rate-limit behaviour is unchanged.
  • automerge_contributor_lane.go:967-979 — the new length bookkeeping (len(" repo:")+len(owner)+1+len(repo)) equals the length of the qualifier string the old code appended, and the len(chunk) > 0 && guard means a chunk is never empty when flushed. Candidates skipped by contributorSearchSkips fall through to the pre-existing len(candidates) == 0 → nil return at line 911, so the own-repo degradation path is the same one v5 already has.
  • automerge_contributor_unsearchable.go:40-66 — c.clock() (automerge_held_runs.go:260) falls back to time.Now() when c.now is nil, and warn/debug (automerge_sweep_queued.go:677,711) are nil-logger safe. The map reset at 4096 entries follows the selfSkipWarned pattern at automerge_sweep_queued.go:697.
  • The PR body's claims (isolate-on-422, warn once then Debug, 1h TTL keyed by (author, repo)) match what the code does; the tests at automerge_contributor_lane_test.go:1345-1365 cover both the single-repo and whole-author refusal.

One open question, not a defect: searchQueryUnsearchable (automerge_contributor_unsearchable.go:28-31) treats every 422 as "resource cannot be searched". A 422 for a malformed query would also mark each repo in the chunk unsearchable for an hour. The consequence is the same own-repo count the old code already produced plus one WARN per pair, so it degrades safely — just noting it in case a future change wants to match on the message body too.

Checks were still running when I read this (tide pending); nothing here needs a maintainer decision beyond the normal merge.

— 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 full contributorMergedRepos at head (src/pkg/github/automerge/automerge_contributor_lane.go:887-979), the new helpers in automerge_contributor_unsearchable.go, the Engine fields added in automerge_sweep.go:293-297, and the existing clock() (automerge_held_runs.go:260) / warn / debug (automerge_sweep_queued.go:677,711) this relies on. Looks correct to me.

What I verified:

  • Chunk-length accounting (lane.go:960-971) reproduces the old len(query)+len(qualifier) > 256 boundary exactly, including the first-ref-always-added case, so chunking behaviour is unchanged for non-422 paths.
  • Non-422 errors still hit flush → return err → warn("…counting the PR's repository only") → return nil (lane.go:963-975), so the 5xx/rate-limit degradation the PR body describes is intact.
  • searchQueryUnsearchable only matches a *gh.ErrorResponse with status 422 (unsearchable.go:28-31); the other 422s search can return (query >256 chars, paging past 1000) are not reachable here because of the chunk cap and PerPage:100 first-page-only.
  • Cache key, found lookup and repoFromRepositoryURL all lower-case consistently.
  • fixed-17148.md fragment is present and hive-merge.md is updated to describe the new behaviour.

One observation, not a defect: when the author is the refused qualifier (every repo 422s), a chunk of N repos now costs N+1 search calls instead of 1 before the pair cache fills (lane.go:936-951). That is bounded, happens once per author per contributorUnsearchableTTL, and is covered by the "unsearchable author" test case, so I think it is the right trade — just noting it for whoever watches the search budget.

— 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 diff against v5 together with the caller (contributorCleanHistory → automerge_contributor_lane.go:830) and the helpers it leans on (Engine.clock at automerge_held_runs.go:260, warn/debug in automerge_sweep_queued.go). The change does what the body says, and I found no defect.

What I verified:

  • Chunking is behaviour-preserving. The old code appended qualifiers to a string and flushed when len(query)+len(qualifier) > 256; the new loop tracks length the same way (len(" repo:")+len(owner)+1+len(repo)) and flushes with the identical threshold. The added len(chunk) > 0 && guard only changes the degenerate case where a single qualifier alone exceeds 256, which previously produced a silent no-op flush and now still issues the query — strictly better.
  • Non-422 failures keep the pre-#17148 path. flush returns any non-422 error unchanged (automerge_contributor_lane.go, new flush), and both call sites still emit the original repo search failed; counting the PR's repository only warning and return nil, so the caller at :830 falls through to the own-repo count exactly as before. The retest of the generic-failure case with 500 instead of 422 is the right adjustment.
  • The per-repo retry cannot loop. A single-repo 422 is recorded and skipped (len(chunk) == 1 branch); a non-422 on a single repo is returned and degrades the whole search. No path re-asks the same chunk twice in one call.
  • The TTL cache is safe under the engine's clock. contributorSearchSkips / noteContributorUnsearchable take contributorUnsearchableMu around the map and use c.clock(), which falls back to time.Now() when c.now is nil, so production and the fake-clock test share one code path. Resetting the map above 4096 entries bounds memory; the only cost is a repeat WARN for a pair, which is acceptable.
  • Skipped pairs cannot inflate the result. candidates excludes skipped refs before found is built, and out is filtered from candidates, so a skipped repo can never appear in the returned list.

One design note, not a defect: searchQueryUnsearchable treats every 422 from search/issues as "cannot see repository", not just the "listed users and repositories cannot be searched" message. With chunking already keeping queries under 256 chars, the other 422 causes (malformed qualifier, too many operators) do not arise from this query shape, so this is fine today; it is worth knowing if the query ever grows.

Tests cover both the integration path (TestTrySweepContributorLanePRAutoPromotionScope, two new cases) and the exact query sequence across the TTL (TestContributorMergedReposRemembersUnsearchableRepository), and the body's claim that the first new case fails on the parent is consistent with the old code returning nil on any error.

Looks correct to me. This is a fork PR, so a maintainer needs to merge once checks finish.

— 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 change against v5 at 7e19f30 (callers in automerge_contributor_lane.go, Engine in automerge_sweep.go). Looks correct to me.

What I verified

  • contributorHistory (automerge_contributor_lane.go:827) walks the PR's own repository before calling contributorMergedRepos, so the new early return nil when every candidate is inside the skip window (:912) degrades to exactly the pre-#14517 own-repo count — same as a search failure, no new blank spot.
  • The flush closure (:935-954) only re-asks per repo on a 422 (searchQueryUnsearchable); 5xx/rate-limit still take the existing repo search failed path, as the body says. A single-repo chunk that 422s is recorded and skipped rather than retried — no fan-out loop.
  • Chunking (:957-967): len(chunk) > 0 && means an over-long single qualifier gets its own chunk instead of the old query == base no-op flush, so nothing is silently dropped.
  • noteContributorUnsearchable leaves expired keys in the map, so seen survives the TTL and a permanently refused pair warns once per process, then Debug — matches the stated intent. The > 4096 reset would re-WARN once; negligible.
  • c.clock() (automerge_held_runs.go:260) and c.debug (automerge_sweep_queued.go:711) already exist on Engine; the new state is mutex-guarded consistently.
  • TestContributorMergedReposRemembersUnsearchableRepository pins the exact query sequence across the TTL boundary and asserts the old warning never fires — it would fail on the parent, where the first 422 returned nil from the whole function.

One note, not a defect: GitHub also returns 422 for other search validation problems (e.g. a malformed qualifier). With single-repo chunks any 422 is attributed to that repo and cached for an hour. Query length is already bounded by contributorSearchQueryMaxLen, so I could not construct a realistic case; mentioning it only so the 1h TTL is understood as the recovery path if it ever happens.

Docs (hive-merge.md) and the changelog fragment match the behaviour. CI is green.

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

Picks up the v5 fix for TestCloseOnMergeLedgerSweepSettledClaimsSkipAPI, which
failed on the PR's merge-base 58f593d and is green on v5 at bf4b8e7.

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

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

Style/maintainability pass at 2960be0. The new once-per-pair warn cache mirrors the existing warnSelfAuthoredSkipOnce idiom (automerge_sweep_queued.go:686-703) and the TTL goes through c.clock(), so this reads as native to the package. One advisory note:

searchQueryUnsearchable doc describes a narrower check than it implements — src/pkg/github/automerge/automerge_contributor_unsearchable.go:24-31. The comment says it reports GitHub's "cannot be searched" 422, and the WARN text (...search cannot see repository for this author) and the 1h cache both assume that meaning, but the predicate only tests StatusCode == 422. Any other search validation error (bad qualifier, oversized q) would be attributed to a repository and cached for an hour under the same message. Either narrow the predicate to the Search/q/invalid error entry GitHub returns, or reword the comment so the next reader knows it is status-only:

// searchQueryUnsearchable reports whether err is GitHub's 422 Validation
// Failed for a search whose listed users or repositories "cannot be searched
// either because the resources do not exist or you do not have permission to
// view them". It does not say which qualifier it refused.
func searchQueryUnsearchable(err error) bool {
	var ghErr *gh.ErrorResponse
	if !errors.As(err, &ghErr) || ghErr.Response == nil || ghErr.Response.StatusCode != http.StatusUnprocessableEntity {
		return false
	}
	for _, e := range ghErr.Errors {
		if e.Resource == "Search" && e.Field == "q" && e.Code == "invalid" {
			return true
		}
	}
	return false
}

The fake in automerge_contributor_lane_test.go:256-262 already emits that exact error entry, so the tests cover the narrowed form as written. Non-blocking.

— 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

Choose a reason for hiding this comment

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

Read the full diff against v5 plus the surrounding contributorMergedRepos body and the Engine helpers it leans on. This looks correct to me.

What I checked:

  • Chunking invariant — automerge_contributor_lane.go:959-968: the in-loop flush is guarded by len(chunk) > 0 and every iteration appends before the next check, so the final flush(chunk) at :970 never runs with an empty chunk. That matters because search([]) would otherwise issue a bare is:pr is:merged author:X query with no repo: qualifier and count merges hive-wide across any repo. The old query == base early-return is gone, but the guard makes it unreachable.
  • 422 isolation — :935-955: a 422 on a multi-repo chunk re-asks each repo singly; a non-422 error on the single retry still propagates to the existing "counting the PR's repository only" warning, so 5xx/rate-limit behaviour is unchanged from v5.
  • Once-per-process WARN — automerge_contributor_unsearchable.go:54-65: seen is read before the entry is overwritten and entries are never deleted (only the >4096 reset), so a pair that expires and is refused again logs at Debug, exactly as the doc comment and TestContributorMergedReposRemembersUnsearchableRepository state.
  • c.clock() (automerge_held_runs.go:260) and c.debug (automerge_sweep_queued.go:711) exist on Engine; the map is mutex-guarded on both read and write paths.

One non-blocking note for whoever merges: searchQueryUnsearchable treats any 422 from Search.Issues as "unsearchable pair". With the query capped at 256 chars the only other 422 GitHub returns here is a malformed qualifier, which cannot arise from owner/repo tokens, so I agree it is safe — just naming the assumption.

CI is green across the test matrix. I have not approved or changed anything; this is advisory.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

/lgtm

Posted by @clubanderson from the Hive dashboard; the merge gate decides from here.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

@hivecommons-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Posted by @clubanderson from the Hive dashboard; the merge gate decides from here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

/approve

Posted by @clubanderson from the Hive dashboard; the merge gate decides from here.

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

Approved by @clubanderson for Hive auto-merge on green CI.

Approved from the Hive dashboard by @clubanderson as the owner decision on a Ready-for-human-merge pull request; hive merges it on its next merge pass once CI is green.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hivecommons-hive[bot]
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

Copy link
Copy Markdown
Contributor

@hivecommons-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

Approved by @clubanderson for Hive auto-merge on green CI.

Approved from the Hive dashboard by @clubanderson as the owner decision on a Ready-for-human-merge pull request; hive merges it on its next merge pass once CI is green.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@hivecommons-hive hivecommons-hive Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive queued this PR but could not set the prow/lgtm commit status, so Prow may strip the lgtm label and the auto-merge queue may not hold.

@hivecommons-hive
hivecommons-hive Bot merged commit e133faf into hivecommons:v5 Nov 8, 2026
72 of 73 checks passed
@Karibhou
Karibhou deleted the fix/17148-autopromo-search-422 branch November 15, 2026 11:07
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[selfreport] unclassified_error_repeated: contributor-lane auto-promotion repo search failed; counting the PR's repositor…

1 participant