Skip to content

plugin/label: Improve error when adding/removing a restricted label #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

stephenfin
Copy link
Contributor

@stephenfin stephenfin commented May 30, 2025

Currently, if you attempt to add a restricted label and allowed_teams is unset/empty, you get the following unhelpful message.

@username: Can not set label cherry-pick-approved: Must be member in one of these teams: []

Improve this so that we no longer suggest being a member of no team and instead suggest reaching out to one of the users in allowed_users instead:

@username: The label(s) `restricted-label` cannot be applied or removed, because you are not in one of the allowed teams and are not an allowed user. Consider assigning one of the following members: Mallory

We also improve the common path where allowed_teams is populated, aligning the error message with those of other errors paths:

@username: The label(s) `restricted-label` cannot be applied or removed, because you are not in one of the allowed teams and are not an allowed user. Must be a member of one of these teams: privileged-group

Note

I suspect dumping a list of users could get "chatty", so I've intentionally avoided formatting these as links (i.e. we emit user, not @user) and only print up to 3 users. In most cases, this code should not be triggered since projects will usually make use of allowed_teams.

Note

I'm still not entirely happy with this either. For example, see here. That error messages suggests only a member of openshift-staff-engineers can set the label, when in reality there are many users that can set it. Perhaps we should reword this as either-or ("you must be a member of these groups: xyz. Alternatively, consider assigning one of these members: abc"). Open to idea here.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
It's confusing. We also unify the error message with other similar
errors messages and modify existing tests to validate the actual
string.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Provide a breadcrumb to users if they are unable to assign a label *and*
there are no allowed_teams configured.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/plugins Issues or PRs related to prow's plugins for the hook component labels May 30, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: stephenfin
Once this PR has been reviewed and has the lgtm label, please assign cjwagner for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 30, 2025
Copy link

netlify bot commented May 30, 2025

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit d77cd16
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/683984973bb22400095c8534
😎 Deploy Preview https://deploy-preview-469--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@stephenfin
Copy link
Contributor Author

/test pull-prow-integration

That...doesn't look related...

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 30, 2025

@stephenfin: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-prow-unit-test-race-detector-nonblocking d77cd16 link false /test pull-prow-unit-test-race-detector-nonblocking

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@stephenfin
Copy link
Contributor Author

/retest-required

pull-prow-unit-test-race-detector-nonblocking is failing on pkg/interrupts/interrupts_test.go:183, which I'm not touching here.

pull-prow-integration failed on the same test, but again this doesn't look related

@smg247
Copy link
Contributor

smg247 commented Jun 11, 2025

I see no reason why the message can't display the allowed teams and (a subset of) the allowed users as well. You can format a GH message so that it hides content by default to be expanded, maybe if the list is longer than 5 or so you can put an ellipsis, and hide the rest behind it. I am not sure that I would bother with returning random users. In situations where there are 20+ users, maybe just return the first 20... WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugins Issues or PRs related to prow's plugins for the hook component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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.

3 participants