mszostok / codeowners-validator

The GitHub CODEOWNERS file validator
Apache License 2.0
212 stars 47 forks source link

Team does not belong to organization #121

Closed electriquo closed 2 years ago

electriquo commented 2 years ago

Description

Upgrading to version 0.7.0 makes the Github action fail, whereas version 0.6.0 passed. The action is configured as follows

- uses: mszostok/codeowners-validator@v0.7.0
  with:
    checks: files,duppatterns,syntax,owners
    experimental_checks: notowned
    github_access_token: ${{ secrets.GITHUB_PAT }}

With a CODEOWNERS file that looks like so

* @org/team

Expected result

The action should not fail

Actual result

The action fails with the following message

[err] line 1: Team "@org/team" does not belong to "Org" organization.

Steps to reproduce

Since the issue relates to Github organization, unable to share a repository for reproduction

Troubleshooting

Is this a bug in version 0.7.0? Is something missing in the action configuration?

Thank you for your work

mszostok commented 2 years ago

Hi!

Thanks for letting me know!

Root cause

This was a side effect of https://github.com/mszostok/codeowners-validator/pull/78#issuecomment-941445181 where not only team was normalized. Unfortunately, it was not detected by the integration test, as I used only the gh-codeowners organization. As you can see, it's all lower-case.

To reproduce the problem, I created a new organization GitHubCODEOWNERS and executed the v0.7 against it and ran into the same problem: https://github.com/GitHubCODEOWNERS/codeowners-samples/runs/5173200010?check_suite_focus=true

I tested that further to check whether GitHub also is case-insensitive for Organization names:

Corrective and Preventative Measures

To fix that problem, I created this PR: https://github.com/mszostok/codeowners-validator/pull/122 and tested also against a newly created organization: https://github.com/GitHubCODEOWNERS/codeowners-samples/runs/5173279973?check_suite_focus=true

I also added new integration tests against new GitHubCODEOWNERS organization to ensure no regression in the future.


Additional Corrective and Preventative Measures

In this case it's a bit of revers engineering as I don't have access to GitHub code which is responsible for assigning owners. As a result, I will need to create yet another e2e test that will be executed periodically to:

In this way, I will be notified when GitHub will change its behavior and I will be able to release a new version that will match a changed functionality.

electriquo commented 2 years ago

@mszostok THANKS A MILLION any idea when you will release a new version with the fix?

mszostok commented 2 years ago

I will release it in a moment 👍

mszostok commented 2 years ago

@foolioo please let me know if this issue was fixed for you in mszostok/codeowners-validator@v0.7.1🙇 then I will close this issue.

electriquo commented 2 years ago

@mszostok version 0.7.1 works for me