Skip to content

Test failures when hypothesis is available but cannot reach GitHub #132316

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

Closed
kulikjak opened this issue Apr 9, 2025 · 5 comments
Closed

Test failures when hypothesis is available but cannot reach GitHub #132316

kulikjak opened this issue Apr 9, 2025 · 5 comments
Assignees
Labels
infra CI, GitHub Actions, buildbots, Dependabot, etc. type-bug An unexpected behavior, bug, or error

Comments

@kulikjak
Copy link
Contributor

kulikjak commented Apr 9, 2025

Bug report

Bug description:

Hi, we recently started seeing several tests (namely test_binascii, test_math_property, test_tools and test_zoneinfo) to fail due to hypothesis warnings (which were recently turned into errors with #131802):

hypothesis.errors.HypothesisWarning: Authorization failed when trying to download artifact from GitHub. Check that you have a valid GITHUB_TOKEN set in your environment.`

or alternatively with

hypothesis.errors.HypothesisWarning: Could not connect to GitHub to get the latest artifact.

when I restrict the access to the internet.

I see that running with "CI" set in the environment fixes the issue as the problematic profile with GitHubArtifactDatabase is not registered, but that seems more like a lucky workaround.

I am not sure about the solution - maybe it can check whether "GITHUB_TOKEN" is also available? Or maybe the warning should be ignored and not cause the tests to fail.

I also think it should honor -urlfetch and -network options.

CPython versions tested on:

3.13

Operating systems tested on:

Other

Linked PRs

@kulikjak kulikjak added the type-bug An unexpected behavior, bug, or error label Apr 9, 2025
@ZeroIntensity ZeroIntensity added the infra CI, GitHub Actions, buildbots, Dependabot, etc. label Apr 9, 2025
@sobolevn sobolevn self-assigned this Apr 9, 2025
@sobolevn
Copy link
Member

sobolevn commented Apr 9, 2025

Thanks for the report! Working on it.

@hugovk
Copy link
Member

hugovk commented Apr 9, 2025

If it's useful, GitHub Actions also sets a GITHUB_ACTIONS variable:

Always set to true when GitHub Actions is running the workflow. You can use this variable to differentiate when tests are being run locally or by GitHub Actions.

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables

@sobolevn
Copy link
Member

Docs right now state: https://hypothesis.readthedocs.io/en/latest/reference/api.html#hypothesis.database.GitHubArtifactDatabase

You must provide GITHUB_TOKEN as an environment variable. In CI, Github Actions provides this automatically, but it needs to be set manually for local usage. In a developer machine, this would usually be a Personal Access Token. If the repository is private, it’s necessary for the token to have repo scope in the case of a classic token, or actions:read in the case of a fine-grained token.

We need GITHUB_TOKEN for hypothesis to work properly, otherwise it may fail with:

{ 
  "message":"API rate limit exceeded for YOUR_API. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
  "documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

sobolevn added a commit to sobolevn/cpython that referenced this issue Apr 10, 2025
sobolevn added a commit that referenced this issue Apr 10, 2025
…factDatabase` (#132348)

Co-authored-by: Hugo van Kemenade <[email protected]>
@hugovk
Copy link
Member

hugovk commented Apr 10, 2025

Thanks both for the report and the PR!

@hugovk hugovk closed this as completed Apr 10, 2025
@kulikjak
Copy link
Contributor Author

kulikjak commented Apr 10, 2025

Thank you for the fix!

I verified that with this patch all the previously failing tests pass again.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 10, 2025
…ubArtifactDatabase` (pythonGH-132348)

(cherry picked from commit fcf2d07)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
sobolevn added a commit that referenced this issue Apr 10, 2025
…HubArtifactDatabase` (GH-132348) (#132367)

gh-132316: Require `socket` and `GITHUB_TOKEN` env to use `GitHubArtifactDatabase` (GH-132348)
(cherry picked from commit fcf2d07)

Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
seehwan pushed a commit to seehwan/cpython that referenced this issue Apr 16, 2025
…ubArtifactDatabase` (python#132348)

Co-authored-by: Hugo van Kemenade <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra CI, GitHub Actions, buildbots, Dependabot, etc. type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants