Skip to content

Update labeler - #640

Open
mrbobbytables wants to merge 2 commits into
cncf:mainfrom
mrbobbytables:improve-labeler
Open

mrbobbytables wants to merge 2 commits into
cncf:mainfrom
mrbobbytables:improve-labeler

Conversation

@mrbobbytables

Copy link
Copy Markdown
Member

Fixes a few error conditions
Enables use of **
Adds more thorough test conditions

Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
@github-actions github-actions Bot added toc toc specific issue needs-triage Indicates an issue or PR that has not been triaged yet (has a 'triage/foo' label applied) needs-kind Indicates an issue or PR that is missing an issue type or kind (a kind/foo label) needs-priority Indicates an issue or PR missing a priority label needs-area Indicates an issue or PR missing an area label needs-status Indicates an issue or PR missing a status label area/utilities Utilities and helper tools and removed needs-area Indicates an issue or PR missing an area label labels Sep 3, 2026
@mrbobbytables
mrbobbytables requested a balanced review from Copilot September 3, 2026 17:32

Copilot AI 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.

🟡 Changes recommended

Command allowlist ambiguities can authorize malformed commands and remove valid labels before failing.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates the standalone Go labeler to improve matching, validation, error handling, and test coverage.

Changes:

  • Adds typed command rules, strict configuration validation, and ** path matching.
  • Aggregates processing errors and paginates label cleanup.
  • Expands tests and CI checks while aligning the Go version.
File summaries
File Description
utilities/labeler/types.go Adds typed command constraints.
utilities/labeler/README.md Documents command matching.
utilities/labeler/main.go Corrects required argument count.
utilities/labeler/labeler.go Revises matching, validation, and error handling.
utilities/labeler/labeler_test.go Adds regression and configuration tests.
utilities/labeler/Dockerfile Aligns the Go version.
.github/workflows/labeler-build.yml Runs tests and vet in CI.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread utilities/labeler/labeler.go Outdated
Comment on lines +208 to +216
values := append([]string(nil), rule.Spec.MatchList...)
for _, predicate := range rule.Spec.Rules {
values = append(values, predicate.Match)
values = append(values, predicate.MatchList...)
}
argument := ""
if len(argv) > 0 {
argument = argv[0]
}
Comment thread utilities/labeler/labeler.go Outdated
Comment on lines +217 to +221
if slices.Contains(values, argument) {
return true
}
for _, action := range rule.Actions {
if action.Kind == "apply-label" && slices.Contains(values, l.renderLabel(action.Spec.Label, argv)) {
Comment on lines +649 to +650
for _, rule := range cfg.Ruleset {
switch rule.Kind {
Comment on lines +892 to +893
func TestLoadProductionConfig(t *testing.T) {
configFile, err := os.Open("../../.github/labels.yaml")
… validation

- Reject missing arguments when match rules specify an allowlist
- Separate raw-argument constraints from rendered-label constraints in commandAllowed
- Preflight rendered actions before performing any label removals
- Validate matchCondition enum strictly during config loading
- Watch .github/labels.yaml in labeler build CI workflow

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
@mrbobbytables

Copy link
Copy Markdown
Member Author

Addressed the review feedback:

  • Filtered empty allowlist values and rejected missing arguments when a rule has an allowlist
  • Separated raw-argument constraints from rendered-label constraints in commandAllowed
  • Added preflight checks to executeActions so invalid rendered labels fail before any labels are removed
  • Added validation for matchCondition enum (must be AND or NOT) during configuration loading
  • Added .github/labels.yaml to labeler-build.yml path filters

🐝 Hive Agent: contributor | SHA: unknown

@mrbobbytables

Copy link
Copy Markdown
Member Author

Addressed review comments in 3a0ebed:

  • Filter empty values and reject bare commands when rules specify an allowlist
  • Separate raw-argument constraints from rendered-label constraints in commandAllowed
  • Preflight rendered actions before performing any label removals
  • Validate matchCondition enum strictly (AND or NOT) during config loading
  • Include .github/labels.yaml in labeler build CI workflow triggers
  • Added unit tests covering all new validation cases and preflight behavior

🐝 Hive Agent: contributor | SHA: unknown

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

Labels

area/utilities Utilities and helper tools needs-kind Indicates an issue or PR that is missing an issue type or kind (a kind/foo label) needs-priority Indicates an issue or PR missing a priority label needs-status Indicates an issue or PR missing a status label needs-triage Indicates an issue or PR that has not been triaged yet (has a 'triage/foo' label applied) toc toc specific issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants