Ensure verified is required on main branch#4998
Ensure verified is required on main branch#4998jupierce wants to merge 1 commit intoopenshift:mainfrom
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
WalkthroughThe tide-config-manager now ensures that main and master branches are always included in the excluded branches set within the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/branchingconfigmanagers/tide-config-manager/main.go (1)
345-360:⚠️ Potential issue | 🔴 CriticalAdd bounds check for
q.Reposbefore accessing it on line 358.The unconditional insert of
main/masteron line 348 ensures thatbranches.Len() > 0is always true, so the block at lines 357–360 now always executes. The code then accessesq.Repos[0]without checking ifq.Reposis non-empty. SinceTideQuerysupports org-scoped queries with emptyRepos, this will panic with an index out of range error at runtime. Add a length check before indexing, or log the query identifiers differently for org-scoped queries.Suggested fix
if branches.Len() > 0 { - if branches.Intersection(gae.openshiftReleaseBranchesPlus1).Len() == 0 && !gae.excludedAllowList.Has(q.Repos[0]) { - fmt.Printf("Suspicious complement query (without %s): %s\n", gae.future, q.Repos) + repoScoped := len(q.Repos) > 0 + if branches.Intersection(gae.openshiftReleaseBranchesPlus1).Len() == 0 && + (!repoScoped || !gae.excludedAllowList.Has(q.Repos[0])) { + fmt.Printf("Suspicious complement query (without %s): repos=%v orgs=%v\n", gae.future, q.Repos, q.Orgs) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/branchingconfigmanagers/tide-config-manager/main.go` around lines 345 - 360, The code unconditionally indexes q.Repos[0] inside the branches.Len() > 0 block which can panic for org-scoped queries with empty q.Repos; update the condition or the logging so you only access q.Repos[0] when len(q.Repos) > 0 (e.g. change the if to check len(q.Repos) > 0 && !gae.excludedAllowList.Has(q.Repos[0]) ), and for the else (org-scoped) path avoid indexing by logging the org or the full query object instead; reference q.Repos, gae.excludedAllowList, branches, and the suspicious printf call to locate where to add the length check and alternate logging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@cmd/branchingconfigmanagers/tide-config-manager/main.go`:
- Around line 345-360: The code unconditionally indexes q.Repos[0] inside the
branches.Len() > 0 block which can panic for org-scoped queries with empty
q.Repos; update the condition or the logging so you only access q.Repos[0] when
len(q.Repos) > 0 (e.g. change the if to check len(q.Repos) > 0 &&
!gae.excludedAllowList.Has(q.Repos[0]) ), and for the else (org-scoped) path
avoid indexing by logging the org or the full query object instead; reference
q.Repos, gae.excludedAllowList, branches, and the suspicious printf call to
locate where to add the length check and alternate logging.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d86fe034-5799-4d81-a6b9-3c3063f0ec78
📒 Files selected for processing (1)
cmd/branchingconfigmanagers/tide-config-manager/main.go
|
@jupierce: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jmguzik, jupierce The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold |
|
second thoughts: I am thinking main/master should be added only if other main/master query exists, wdyt @jupierce ? |
Summary by CodeRabbit