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

fix: try two public urls for maintainer exists lint #2171

Merged
merged 5 commits into from
Nov 27, 2024
Merged

Conversation

beckermr
Copy link
Member

@beckermr beckermr commented Nov 27, 2024

Checklist

  • Added a news entry
  • Regenerated schema JSON if schema altered (python conda_smithy/schema.py)

This PR fixes #2164 by using two public URLs to check if the maintainer exists instead of using the github API anonymously. Hopefully it is more robust since the anonymous API has pretty restructive rate limits.

@beckermr
Copy link
Member Author

cc @jakirkham @h-vetinari

@beckermr beckermr marked this pull request as ready for review November 27, 2024 12:31
@beckermr beckermr requested a review from a team as a code owner November 27, 2024 12:31
@beckermr
Copy link
Member Author

@conda-forge/core this one is ready for review!

Copy link
Member

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

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

Thank you!

@beckermr beckermr merged commit 79183e2 into main Nov 27, 2024
2 checks passed
@jaimergp
Copy link
Member

jaimergp commented Nov 27, 2024

Ah, I was about to suggest that we don't need a GET here, a HEAD is enough:

>>> requests.head("https://github.com/jaimergggggg").status_code
404
>>> requests.head("https://github.com/orgs/jaimergggggg/teams", allow_redirects=False).status_code
404
requests.head("https://github.com/jaimergp").status_code
200
>>> requests.head("https://github.com/orgs/jaimergp/teams", allow_redirects=False).status_code
404
requests.head("https://github.com/conda-forge").status_code
200
>>> requests.head("https://github.com/orgs/conda-forge/teams", allow_redirects=False).status_code
302

Note also that the org check returns 302, not 200. So the code should be:

        req_profile = requests.head(
            f"https://github.com/{maintainer}",
            allow_redirects=False,
        )
        is_user = req_profile.status_code == 200
        req_org = requests.head(
            f"https://github.com/orgs/{maintainer}/teams",
            allow_redirects=False,
        )
        is_org = req_org.status_code in (200, 301, 302) # just to be safe

@jaimergp
Copy link
Member

cc @beckermr ^

@beckermr
Copy link
Member Author

I'll follow up with these improvements in another pr.

@beckermr
Copy link
Member Author

Thank you!

@beckermr beckermr deleted the fix-user-find branch November 27, 2024 23:45
else:
return (
requests.get(
f"https://api.github.com/users/{maintainer}"

This comment was marked as spam.

except github.UnknownObjectException:
return False
return True

This comment was marked as spam.

except github.UnknownObjectException:
return False

This comment was marked as spam.

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.

BUG: spurious failures in linter not finding maintainers / failures in test_maintainer_exists
4 participants