python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.76k stars 2.27k forks source link

HTTP 400 when adding package hosted in a private PyPi #3597

Closed HugoManoMano closed 2 years ago

HugoManoMano commented 3 years ago

Issue

Hi folks :wave: I'm trying to add a private Python package as a dependency of my current project, as per specified in the gist above, but it fails with the trace below.

I have also set-up http identification like this: poetry config http-basic.mypypi USER PASSWORD

Which is valid authentification (everything works fine with pip by adding the same conf in pip.conf file)

N.B. found this issue which seems the exact same one but on a previous poetry version, and which has been closed without being resolved apparently (the manual modification of poetry scripts is not OK for us because we need CI pipeline to run with poetry)

Here is the trace:

 Stack trace:

  25  ~/.poetry/lib/poetry/_vendor/py3.6/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│ 
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

  24  ~/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

  23  ~/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py:171 in _do_handle
       169│         handler_method = self._config.handler_method
       170│ 
     → 171│         return getattr(handler, handler_method)(args, io, self)
       172│ 
       173│     def __repr__(self):  # type: () -> str

  22  ~/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py:92 in wrap_handle
        90│         self._command = command
        91│ 
     →  92│         return self.handle()
        93│ 
        94│     def handle(self):  # type: () -> Optional[int]

  21  ~/.poetry/lib/poetry/console/commands/add.py:174 in handle
       172│ 
       173│         try:
     → 174│             status = self._installer.run()
       175│         except Exception:
       176│             self.poetry.file.write(original_content)

  20  ~/.poetry/lib/poetry/installation/installer.py:103 in run
       101│         local_repo = Repository()
       102│ 
     → 103│         return self._do_install(local_repo)
       104│ 
       105│     def dry_run(self, dry_run=True):  # type: (bool) -> Installer

  19  ~/.poetry/lib/poetry/installation/installer.py:235 in _do_install
       233│             )
       234│ 
     → 235│             ops = solver.solve(use_latest=self._whitelist)
       236│         else:
       237│             self._io.write_line("Installing dependencies from lock file")

  18  ~/.poetry/lib/poetry/puzzle/solver.py:65 in solve
        63│         with self._provider.progress():
        64│             start = time.time()
     →  65│             packages, depths = self._solve(use_latest=use_latest)
        66│             end = time.time()
        67│ 

  17  ~/.poetry/lib/poetry/puzzle/solver.py:234 in _solve
       232│         try:
       233│             result = resolve_version(
     → 234│                 self._package, self._provider, locked=locked, use_latest=use_latest
       235│             )
       236│ 

  16  ~/.poetry/lib/poetry/mixology/__init__.py:7 in resolve_version
       5│     solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
       6│ 
     → 7│     return solver.solve()
       8│ 

  15  ~/.poetry/lib/poetry/mixology/version_solver.py:84 in solve
        82│             while next is not None:
        83│                 self._propagate(next)
     →  84│                 next = self._choose_package_version()
        85│ 
        86│             return self._result()

  14  ~/.poetry/lib/poetry/mixology/version_solver.py:397 in _choose_package_version
       395│             version = locked
       396│ 
     → 397│         version = self._provider.complete_package(version)
       398│ 
       399│         conflict = False

  13  ~/.poetry/lib/poetry/puzzle/provider.py:437 in complete_package
       435│                     package.version.text,
       436│                     extras=list(package.dependency.extras),
     → 437│                     repository=package.dependency.source_name,
       438│                 ),
       439│             )

  12  ~/.poetry/lib/poetry/repositories/pool.py:135 in package
       133│             for idx, repo in enumerate(self._repositories):
       134│                 try:
     → 135│                     package = repo.package(name, version, extras=extras)
       136│                 except PackageNotFound:
       137│                     continue

  11  ~/.poetry/lib/poetry/repositories/legacy_repository.py:323 in package
       321│             return self._packages[index]
       322│         except ValueError:
     → 323│             package = super(LegacyRepository, self).package(name, version, extras)
       324│             package._source_type = "legacy"
       325│             package._source_url = self._url

  10  ~/.poetry/lib/poetry/repositories/pypi_repository.py:158 in package
       156│         extras=None,  # type: (Union[list, None])
       157│     ):  # type: (...) -> Package
     → 158│         return self.get_release_info(name, version).to_package(name=name, extras=extras)
       159│ 
       160│     def search(self, query):

   9  ~/.poetry/lib/poetry/repositories/pypi_repository.py:224 in get_release_info
       222│ 
       223│         cached = self._cache.remember_forever(
     → 224│             "{}:{}".format(name, version), lambda: self._get_release_info(name, version)
       225│         )
       226│ 

   8  ~/.poetry/lib/poetry/_vendor/py3.6/cachy/repository.py:174 in remember_forever
       172│             return val
       173│ 
     → 174│         val = value(callback)
       175│ 
       176│         self.forever(key, val)

   7  ~/.poetry/lib/poetry/_vendor/py3.6/cachy/helpers.py:6 in value
       4│ def value(val):
       5│     if callable(val):
     → 6│         return val()
       7│ 
       8│     return val

   6  ~/.poetry/lib/poetry/repositories/pypi_repository.py:224 in <lambda>
       222│ 
       223│         cached = self._cache.remember_forever(
     → 224│             "{}:{}".format(name, version), lambda: self._get_release_info(name, version)
       225│         )
       226│ 

   5  ~/.poetry/lib/poetry/repositories/legacy_repository.py:377 in _get_release_info
       375│         data.files = files
       376│ 
     → 377│         info = self._get_info_from_urls(urls)
       378│ 
       379│         data.summary = info.summary

   4  ~/.poetry/lib/poetry/repositories/pypi_repository.py:410 in _get_info_from_urls
       408│             # Prefer non platform specific wheels
       409│             if universal_python3_wheel:
     → 410│                 return self._get_info_from_wheel(universal_python3_wheel)
       411│ 
       412│             if universal_python2_wheel:

   3  ~/.poetry/lib/poetry/repositories/pypi_repository.py:431 in _get_info_from_wheel
       429│         with temporary_directory() as temp_dir:
       430│             filepath = Path(temp_dir) / filename
     → 431│             self._download(url, str(filepath))
       432│ 
       433│             return PackageInfo.from_wheel(filepath)

   2  ~/.poetry/lib/poetry/repositories/pypi_repository.py:450 in _download
       448│ 
       449│     def _download(self, url, dest):  # type: (str, str) -> None
     → 450│         return download_file(url, dest, session=self.session)
       451│ 
       452│     def _log(self, msg, level="info"):

   1  ~/.poetry/lib/poetry/utils/helpers.py:99 in download_file
        97│ 
        98│     with get(url, stream=True) as response:
     →  99│         response.raise_for_status()
       100│ 
       101│         with open(dest, "wb") as f:

  HTTPError

  400 Client Error: Bad Request for url: https://XXXXXX.s3.amazonaws.com/pypi/08ef/mypackage/mypackage-0.4.3-py3-none-any.whl?Expires=1611335583&Signature=XXX&AWSAccessKeyId=XXX&x-amz-security-token=XXX

  at ~/.poetry/lib/poetry/_vendor/py3.6/requests/models.py:941 in raise_for_status
      937│         elif 500 <= self.status_code < 600:
      938│             http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
      939│ 
      940│         if http_error_msg:
    → 941│             raise HTTPError(http_error_msg, response=self)
      942│ 
      943│     def close(self):
      944│         
      945│         called the underlying ``raw`` object must not be accessed again.
tharwan commented 3 years ago

We ran into the same issue. We reverted back to the old version of poetry by pinning the version in our build chain.

pkoch commented 2 years ago

Same issue. On AWS CodeArtifact, even though that doesn't look like it'd make a difference.

neersighted commented 2 years ago

Closing as I can't reproduce this against AWS on 1.2.x. If you are hitting this, please open an issue and stand up a test instance of your PyPI server if at all possible. If not, pairing with an interested maintainer and introspecting your local copy of Poetry is likely the next best bet, if at all possible.

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.