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

Add handling for when author is null #38

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

Conversation

wallentx
Copy link

@wallentx wallentx commented Apr 6, 2024

There are some very specific conditions where a user who has not signed the CLA can still have their PR pass the cla-check workflow if they rebase, and push commits that were authored by someone who has signed the CLA, but their author information returns null.

wallentx/lightdm#3
https://github.com/wallentx/lightdm/pull/3/commits

In the above example, the true contributor details are:

[
    {
        "username": "wallentx",
        "email": "[email protected]",
        "signed": false
    },
    {
        "username": null,
        "email": "[email protected]",
        "signed": false
    },
    {
        "username": "madpilot78",
        "email": "[email protected]",
        "signed": false
    },
    {
        "username": "n3rdopolis",
        "email": "[email protected]",
        "signed": false
    }
]

But without handling of null, the list gets deformed, and is processed as:

[
    {
        "username": "wallentx",
        "email": "[email protected]",
        "signed": false
    },
    {
        "username": "madpilot78",
        "email": "[email protected]",
        "signed": false
    },
    {
        "username": "n3rdopolis",
        "email": "[email protected]",
        "signed": false
    }
]

And so during the CI run, you see:

Checking the following users on GitHub:
- wallentx ✕ (issue checking CLA status [HttpError: User does not exist or is not a public member of the organization])
- madpilot78 ✕ (issue checking CLA status [HttpError: User does not exist or is not a public member of the organization])
- n3rdopolis ✕ (issue checking CLA status [HttpError: User does not exist or is not a public member of the organization])

Checking the following users on Launchpad:
- [email protected] ✓ (has signed the CLA)
- [email protected] ✓ (has signed the CLA)
- [email protected] ✓ (has signed the CLA)

CLA Check - PASSED

The GitHub API is unable to derive the GitHub username for guido (https://github.com/gber) from the query being used (I don't actually know if there's a GH API endpoint that will allow you to discover that if their commit can't be associated with a REF), so the author information shows up as null, which I guess the prior record ends up taking its place. my email address is never checked against Launchpad, because it slotted me down into the null spot.
This check should not have passed, because I have never signed the CLA.
https://github.com/wallentx/lightdm/actions/runs/8579267328/job/23514827215?pr=3

Copy link

github-actions bot commented Apr 6, 2024

Everyone contributing to this PR have now signed the CLA. Thanks!

@wallentx
Copy link
Author

wallentx commented Apr 6, 2024

The funny thing is that I DID sign the CLA, or at least I thought I did, back when I made this PR canonical/lightdm#340 which is where I first noticed this cla-check erroneously passing. I do indeed have a launchpad ID that I set up when I created a Ubuntu One account in the process of getting the CLA stuff done, but I either did it wrong, or need to do it again.. but I don't want to fix it, and break my working examples of this cla-check bug. 🙃
Anyway, if someone can verify that they do indeed understand what I'm describing, and give me the all-clear, I'll attempt to fix my CLA stuff so that CI will ✔️ so that this PR can move forward.

(or I can try and find some odd commit to rebase and trick CI into passing 😉)

@beliaev-maksim
Copy link
Member

@wallentx how will it work in case if we have several people with null as authors, will not this override the dictionary ?

wallentx added 2 commits July 2, 2024 17:35
* Update index.js

* Update index.js

* Update index.js
@wallentx
Copy link
Author

wallentx commented Jul 2, 2024

@beliaev-maksim I apologize for the delay in response. I believe that it should have handled multiple null users fine, but I went ahead and made some changes so that it explicitly fails over to email to evaluate each contributor.

Additionally, it was not deduplicating the list of contributors, and would make multiple calls for each entry. I made some changes to consolidate everything into a map.

I also injected some fake user contributions into the list on a separate test branch to see how it handled multiple null user values, and it seems to have handled it appropriately: https://github.com/wallentx/lightdm/actions/runs/9768213649/job/26966206071?pr=4

Oh, I also included conditional debug logging so that it prints the contributor list that it is working against (like the output in the run above) that is only executed if the github actions run is in debug mode.

Some of that is extra, so feel free to make whatever changes you feel, as you see fit.

index.js Outdated
Comment on lines 33 to 36
core.startGroup('Installing python3-launchpadlib');
await exec.exec('sudo apt-get update');
await exec.exec('sudo apt-get install python3-launchpadlib');
core.endGroup()
core.endGroup();
Copy link
Member

Choose a reason for hiding this comment

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

please move all the styling changes into a separate PR

Copy link
Author

Choose a reason for hiding this comment

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

@beliaev-maksim done! plz let me know if anything still looks opinionated

Comment on lines +118 to +122
try {
await ghRepo.request('GET /users/' + username);
} catch (error) {
console.log('- ' + username + ' ✕ (GitHub user does not exist)');
continue;
Copy link
Member

Choose a reason for hiding this comment

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

why do we need this part ?

passed = false;
non_signers.push(i)
break;
Copy link
Member

Choose a reason for hiding this comment

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

why do not we break anymore ?

@beliaev-maksim
Copy link
Member

@wallentx
I still see that this PR could be easily split into 4:

  1. pure style change
  2. code refactoring let, var, semicolons, etc
  3. adding GH debug output
  4. handling when author is null

if that is submitted as 4 separate PRs, then we can do the review a way faster for each of the PRs

Now, the burden is on the repo maintainers to understand which changes belong to which group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants