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

pip ignores index pages with Content-Type not defined in PEP 691 #11340

Open
hmstepanek opened this issue Aug 2, 2022 · 4 comments · May be fixed by #11354
Open

pip ignores index pages with Content-Type not defined in PEP 691 #11340

hmstepanek opened this issue Aug 2, 2022 · 4 comments · May be fixed by #11354
Labels
state: needs discussion This needs some more discussion type: bug A confirmed bug or unintended behavior

Comments

@hmstepanek
Copy link

hmstepanek commented Aug 2, 2022

Description

Our github action's CI has been failing sporadically with the following errors since 7/26:

Example 1:

https://github.com/newrelic/newrelic-python-agent/runs/7621668567?check_suite_focus=true

WARNING: Skipping page https://pypi.org/simple/pytest/ because the GET request got Content-Type: Unknown. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/html
ERROR: Could not find a version that satisfies the requirement pytest==6.2.5 (from versions: none)
ERROR: No matching distribution found for pytest==6.2.5

Example 2:

https://github.com/newrelic/newrelic-python-agent/runs/7621668309?check_suite_focus=true

WARNING: Skipping page https://pypi.org/simple/beautifulsoup4/ because the GET request got Content-Type: Unknown. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/html
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of pytest to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement beautifulsoup4 (from webtest) (from versions: none)
ERROR: No matching distribution found for beautifulsoup4

We tried explicitly disabling the caching directory but this did not fix the issue. At around the same time this issue began, we noticed the following issue was filled in the pip repo: pypi/warehouse#11949. We also noticed that the following issue appears to be the same issue we are running into now though the root cause may be different: #5345.

Expected behavior

.tox/postgres-datastore_psycopg2-py39-psycopg20208/bin/pip install pytest==6.2.5 succeeds.

pip version

22.2.1

Python version

I have personally seen failures on 3.9.13, 3.8.13, 2.7.18. These failures appear to be independent of the Python version.

OS

Ubuntu 20.04.4 LTS

How to Reproduce

  1. Kick off a test run by clicking the refresh icon (labeled "Re-run this job") on this page.
    image and continue to do so until the tests fail (sometimes it fails the first time, sometimes it takes 2 or 3 runs to fail).

**Note we have not been able to reproduce this locally on our machines, only inside our Github Actions CI.

Output

https://github.com/newrelic/newrelic-python-agent/runs/7634470208?check_suite_focus=true

[9046] /home/runner/work/newrelic-python-agent/newrelic-python-agent$ /home/runner/work/newrelic-python-agent/newrelic-python-agent/.tox/postgres-datastore_psycopg2-py39-psycopg20208/bin/pip install pytest==6.2.5 iniconfig pytest-cov WebTest==2.0.35 'psycopg2-binary<2.9'
WARNING: Skipping page https://pypi.org/simple/pytest/ because the GET request got Content-Type: Unknown. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/html
ERROR: Could not find a version that satisfies the requirement pytest==6.2.5 (from versions: none)
ERROR: No matching distribution found for pytest==6.2.5
ERROR: invocation failed (exit code 1)
ERROR: could not install deps [pytest==6.2.5, iniconfig, pytest-cov, WebTest==2.0.35, psycopg2-binary<2.9]; v = InvocationError("/home/runner/work/newrelic-python-agent/newrelic-python-agent/.tox/postgres-datastore_psycopg2-py39-psycopg20208/bin/pip install pytest==6.2.5 iniconfig pytest-cov WebTest==2.0.35 'psycopg2-binary<2.9'", 1)
postgres-datastore_psycopg2-py39-psycopg20208 finish: getenv /home/runner/work/newrelic-python-agent/newrelic-python-agent/.tox/postgres-datastore_psycopg2-py39-psycopg20208 after 1.94 seconds
cleanup /home/runner/work/newrelic-python-agent/newrelic-python-agent/.tox/.tmp/package/2/newrelic-0.0.zip

=================================== log end ====================================
✖ FAIL postgres-datastore_psycopg2-py39-psycopg20208 in 4.419 seconds
postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207 uses /opt/hostedtoolcache/Python/3.6.15/x64/bin/python3.6
postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207 start: parallel postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207 
[9112] /home/runner/work/newrelic-python-agent/newrelic-python-agent$ /opt/hostedtoolcache/Python/3.10.5/x64/bin/python3.10 /opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/tox/__main__.py -vv -e postgres-datastore_asyncpg-py37,postgres-datastore_asyncpg-py39,postgres-datastore_postgresql-py36,postgres-datastore_postgresql-py38,postgres-datastore_psycopg2-py27-psycopg20208,postgres-datastore_psycopg2-py37-psycopg20208,postgres-datastore_psycopg2-py39-psycopg20208,postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207,postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208,postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 -p auto --installpkg .tox/.tmp/package/1/newrelic-0.0.zip >.tox/postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207/log/postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207-0.log
postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207 finish: parallel postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207  after 20.55 seconds
✔ OK postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207 in 20.555 seconds
pypy (/opt/hostedtoolcache/PyPy/2.7.18/x64/bin/pypy) is {'executable': '/opt/hostedtoolcache/PyPy/2.7.18/x64/bin/pypy', 'implementation': 'PyPy', 'version_info': [2, 7, 18, 'final', 42], 'version': '2.7.18 (8e99af2f9b8e3a58dd8691378a36ef43c3139ee9, Mar 29 2022, 05:16:07)\n[PyPy 7.3.9 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]', 'is_64': True, 'sysplatform': 'linux2', 'os_sep': '/', 'extra_version_info': [7, 3, 9, 'final', 0]}
postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207 uses /opt/hostedtoolcache/PyPy/2.7.18/x64/bin/pypy
postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207 start: parallel postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207 
[9962] /home/runner/work/newrelic-python-agent/newrelic-python-agent$ /opt/hostedtoolcache/Python/3.10.5/x64/bin/python3.10 /opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/tox/__main__.py -vv -e postgres-datastore_asyncpg-py37,postgres-datastore_asyncpg-py39,postgres-datastore_postgresql-py36,postgres-datastore_postgresql-py38,postgres-datastore_psycopg2-py27-psycopg20208,postgres-datastore_psycopg2-py37-psycopg20208,postgres-datastore_psycopg2-py39-psycopg20208,postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207,postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208,postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 -p auto --installpkg .tox/.tmp/package/1/newrelic-0.0.zip >.tox/postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207/log/postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207-0.log
postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207 finish: parallel postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207  after 21.97 seconds
✔ OK postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207 in 21.973 seconds
postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208 uses /opt/hostedtoolcache/Python/3.7.13/x64/bin/python3.7
postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208 start: parallel postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208 
[10603] /home/runner/work/newrelic-python-agent/newrelic-python-agent$ /opt/hostedtoolcache/Python/3.10.5/x64/bin/python3.10 /opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/tox/__main__.py -vv -e postgres-datastore_asyncpg-py37,postgres-datastore_asyncpg-py39,postgres-datastore_postgresql-py36,postgres-datastore_postgresql-py38,postgres-datastore_psycopg2-py27-psycopg20208,postgres-datastore_psycopg2-py37-psycopg20208,postgres-datastore_psycopg2-py39-psycopg20208,postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207,postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208,postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 -p auto --installpkg .tox/.tmp/package/1/newrelic-0.0.zip >.tox/postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208/log/postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208-0.log
postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208 finish: parallel postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208  after 20.76 seconds
✔ OK postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208 in 20.764 seconds
postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 uses /opt/hostedtoolcache/Python/3.9.13/x64/bin/python3.9
postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 start: parallel postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 
[11484] /home/runner/work/newrelic-python-agent/newrelic-python-agent$ /opt/hostedtoolcache/Python/3.10.5/x64/bin/python3.10 /opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/tox/__main__.py -vv -e postgres-datastore_asyncpg-py37,postgres-datastore_asyncpg-py39,postgres-datastore_postgresql-py36,postgres-datastore_postgresql-py38,postgres-datastore_psycopg2-py27-psycopg20208,postgres-datastore_psycopg2-py37-psycopg20208,postgres-datastore_psycopg2-py39-psycopg20208,postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207,postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207,postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208,postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 -p auto --installpkg .tox/.tmp/package/1/newrelic-0.0.zip >.tox/postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208/log/postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208-0.log
postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207 finish: parallel postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207  after 27.38 seconds
✔ OK postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207 in 29.762 seconds
postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 finish: parallel postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208  after 20.10 seconds
✔ OK postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208 in 20.1 seconds
___________________________________ summary ____________________________________
  postgres-datastore_asyncpg-py37: commands succeeded
  postgres-datastore_asyncpg-py39: commands succeeded
  postgres-datastore_postgresql-py36: commands succeeded
  postgres-datastore_postgresql-py38: commands succeeded
  postgres-datastore_psycopg2-py27-psycopg20208: commands succeeded
  postgres-datastore_psycopg2-py37-psycopg20208: commands succeeded
ERROR:   postgres-datastore_psycopg2-py39-psycopg20208: parallel child exit code 1
  postgres-datastore_psycopg2cffi-py27-psycopg2cffi0207: commands succeeded
  postgres-datastore_psycopg2cffi-py36-psycopg2cffi0207: commands succeeded
  postgres-datastore_psycopg2cffi-pypy-psycopg2cffi0207: commands succeeded
  postgres-datastore_psycopg2cffi-py37-psycopg2cffi0208: commands succeeded
  postgres-datastore_psycopg2cffi-py39-psycopg2cffi0208: commands succeeded
cleanup /home/runner/work/newrelic-python-agent/newrelic-python-agent/.tox/.tmp/package/1/newrelic-0.0.zip
Error: Process completed with exit code 1.


### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).
@hmstepanek hmstepanek added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Aug 2, 2022
@uranusjr
Copy link
Member

uranusjr commented Aug 3, 2022

This looks like a PyPI bug.

Skipping page https://pypi.org/simple/pytest/ because the GET request got Content-Type: Unknown

But that is not a valid Content-Type value. You should probably report this problem to https://github.com/pypa/warehouse.


For pip, maybe it’s acceptable to always fall back to the HTML parser if the Content-Type is invalid? PEP 503 does not specify what Content-Type the server should use…? @dstufft

@uranusjr uranusjr changed the title pip install fails with "GET request got Content-Type: Unknown." pip ignores index pages with Content-Type not defined in PEP 691 Aug 5, 2022
@uranusjr uranusjr added state: needs discussion This needs some more discussion and removed S: needs triage Issues/PRs that need to be triaged labels Aug 5, 2022
@uranusjr uranusjr linked a pull request Aug 5, 2022 that will close this issue
@joerick
Copy link

joerick commented Oct 8, 2022

I don't think this is a warehouse issue. We see this in cibuildwheel quite a bit too - I've been tracking it at pypa/cibuildwheel#1254 , with examples of failures on 22.2.2 and 21.3.1.

I have a minimal recreation of the crash here - https://github.com/joerick/pip-concurrency-debug . Or see this actions run - ignore the cleanup errors after the crash.

My theory is that this is related to concurrent access to pip's cache (that was also an issue a few years back, in #5345 - which gave me the idea). But I can only get the crash to reliably recreate when running different versions of pip at the same time. That is something that our integration tests on cibuildwheel do, because we run tests in parallel, and run different versions of Pip because we still support Python 3.6. I note that the newrelic crash above also is running tests in parallel via tox, and is running different versions of pip for the same reason- old versions of python.

In terms of specific versions, here are results from my tests-

pip versions running simultaneously result
22.2.2, 21.3.1, 20.3.4 💥
20.3.4
22.2.2
21.3.1
21.3.1, 20.3.4
22.2.2, 21.3.1, 20.3.4 💥
22.2.2, 20.3.4 💥
22.2.2, 21.3.1 💥
22.2.2, 22.2.1
22.2, 22.1.2 💥

So the issue seems to be using pip<22.2 and pip>=22.2 at the same time. Note that I have to spin up 10 concurrent threads constantly installing/uninstalling to hit this semi-reliably, so it's not easy to recreate!

Giving each pip version a separate PIP_CACHE_DIR appears to fix the issue, which seems to implicate the shared cache as the source of the problems. @hmstepanek I'd be very curious if you newrelic folks find that separate cache dirs alleviates the issue for you. The errors on cibuildwheel's CI are too sporadic to test any workaround there, and the runs take far too long.

@hmstepanek
Copy link
Author

@joerick Thank you for the insight! What you said makes total sense and would explain why not a lot of people seem to have this issue. I was beginning to wonder if it was just us. 🙈 I will give that workaround a try and see if it fixes the issue!

@hmstepanek
Copy link
Author

We were able to resolve this by disabling the cache when running pip on python 2.7. See Fix Pip Concurrency Issues for details. So we can confirm it does appear to be an issue with pip caches across pip versions.

dairiki added a commit to dairiki/lektor that referenced this issue Feb 28, 2023
I've been experiencing sporadic failures when running tox in parallel mode.
The crux of the error messages when this happens appears to be something like:

```
WARNING: Skipping page https://pypi.org/simple/coverage/ because the GET request got Content-Type: Unknown. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/html
ERROR: Could not find a version that satisfies the requirement
coverage[toml] (from versions: none)
```

It may be this issue: pypa/pip#11340

Setting `download=true` — which tells tox to upgrade pip to the latest version —
seems to fix the issue for me.
dairiki added a commit to lektor/lektor that referenced this issue Apr 3, 2023
When running `tox parallel`, sometimes a testenv will fail with a
"Skipping page https://pypi.org/simple/... because the GET request got
Content-Type: Unknown".  This appears to be an issue associated with shared
access to pip's download cache.

Probably related: pypa/pip#11340

Setting `download=true` to force the use of the most recent release of
pip appears to fix the issue for all but python 3.6.  (For py36, here we
tell pip to use its own private cache.)
kronos30 added a commit to locusrobotics/catkin_virtualenv that referenced this issue Jul 28, 2023
dairiki added a commit to dairiki/lektor that referenced this issue Sep 11, 2023
I've been experiencing sporadic failures when running tox in parallel mode.
The crux of the error messages when this happens appears to be something like:

```
WARNING: Skipping page https://pypi.org/simple/coverage/ because the GET request got Content-Type: Unknown. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/html
ERROR: Could not find a version that satisfies the requirement
coverage[toml] (from versions: none)
```

It may be this issue: pypa/pip#11340

Setting `download=true` — which tells tox to upgrade pip to the latest version —
seems to fix the issue for me.
garyservin added a commit to locusrobotics/catkin_virtualenv that referenced this issue Feb 2, 2024
* Testing with pip cache purge prior to install pip packages

* Tailor: Updating Jenkinsfile

* Adding verbose logging to attempt to catch pypi issue

* Fixing typo

* typos

* formatting with black

* Updating pip version to 22.2.2 as a potential fix for pypa/pip#11340

* Testing with no-cache-dir during install

* Moving option

* Add --no-cache-dir

* Fixing formatting with black

* Tailor: Updating Jenkinsfile

* Tailor: Updating Jenkinsfile

* Tailor: Updating Jenkinsfile

---------

Co-authored-by: locus-services <33065330+locus-services@users.noreply.github.com>
Co-authored-by: Gary Servin <gservin@locusrobotics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion This needs some more discussion type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants