Skip to content
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

Handle empty alias group case #368

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

Conversation

nikhilnishad-goog
Copy link

@nikhilnishad-goog nikhilnishad-goog commented Feb 3, 2025

For this issue. Modifies repoowners.go to handle cases where the file has an alias group but does not have any user name listed in it.

There are multiple acceptable yamls that are being not parsed explictly and edge cases not handled. Examples are -

aliases:
  alias-group:
aliases:
  alias-group: {}
aliases:
  alias-group: {alias1, alias2}
aliases:
  alias-group: ""

All of these are valid yamls, that can cause silent failures like the one mentioned in #360 .

Fixes #360

Copy link

linux-foundation-easycla bot commented Feb 3, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot requested a review from cjwagner February 3, 2025 16:26
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nikhilnishad-goog
Once this PR has been reviewed and has the lgtm label, please assign stevekuznetsov 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 cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Feb 3, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @nikhilnishad-goog!

It looks like this is your first PR to kubernetes-sigs/prow 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/prow has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 3, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @nikhilnishad-goog. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 3, 2025
Copy link

netlify bot commented Feb 3, 2025

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 1c567e6
🔍 Latest deploy log https://app.netlify.com/sites/k8s-prow/deploys/67a486531acbd60008a1560b
😎 Deploy Preview https://deploy-preview-368--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 site configuration.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 3, 2025
@nikhilnishad-goog
Copy link
Author

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@nikhilnishad-goog: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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.

@nikhilnishad-goog
Copy link
Author

/assign @tuminoid

@matthyx
Copy link
Contributor

matthyx commented Feb 3, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 3, 2025
@nikhilnishad-goog
Copy link
Author

/test pull-prow-integration

Copy link
Contributor

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look!

Took initial look at this, mostly nits.

I'm also thinking if we really should error out in unmarshalling the aliases, or just gracefully accept a group was empty and did not add any usernames. As a user, I'd kinda hate the fact that if I don't have any people left in a group, I'd need to comment out the alias and everywhere it is referred.

pkg/plugins/verify-owners/verify-owners_test.go Outdated Show resolved Hide resolved
pkg/repoowners/repoowners_test.go Outdated Show resolved Hide resolved
pkg/repoowners/repoowners_test.go Outdated Show resolved Hide resolved
@nikhilnishad-goog
Copy link
Author

@tuminoid Thanks for taking a look.

I'm also thinking if we really should error out in unmarshalling the aliases, or just gracefully accept a group was empty and did not add any usernames. As a user, I'd kinda hate the fact that if I don't have any people left in a group, I'd need to comment out the alias and everywhere it is referred.

I am in the opinion of throwing when unmarshalling, ideally, there should be no dead code (which includes empty groups that are not meant to have any effect anywhere). The tests should match that behavior.

Also, there are some missed cases, i will update the PR soon.

// Convert []interface{} to []string
var members []string
for _, member := range v {
members = append(members, member.(string))
Copy link
Contributor

@jmguzik jmguzik Feb 4, 2025

Choose a reason for hiding this comment

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

Suggested change
members = append(members, member.(string))
str, ok := member.(string)
if !ok {
return result, fmt.Errorf(....)
}

type check here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Prow accepted invalid OWNERS_ALIASES change and broke approvals
5 participants