Skip to content

Poetry crashes when using poetry publish --skip-existing with Nexus OSS #10602

@kisev

Description

@kisev

Description

I use Poetry with Nexus OSS 3.75.1-01 and the --skip-existing flag doesn't work as expected.

Currently supported return codes and error messages are - here

I'm not sure which Nexus OSS version introduced the new error message, but in my setup I get 400 cannot be updated instead of the expected 400 updating asset.

In my opinion, Poetry should support the new error message as well (without changing the old behavior).

Workarounds

  • Find the Nexus OSS version that introduced the new error message and downgrade to it (not possible in my case)
  • Implement a check before running poetry publish for Nexus OSS PyPi repositories with immutable settings enabled

Poetry Installation Method

pip

Operating System

Ubuntu 20.04

Poetry Version

2.2.1

Poetry Configuration

cache-dir = "/home/kisev/.cache/pypoetry"
data-dir = "/home/kisev/.local/share/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python"  # /home/kisev/.local/share/pypoetry/python
repositories.pypi-proxy.url = "https://***/repository/pypi-proxy/simple"
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/kisev/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

Example pyproject.toml

Poetry Runtime Logs

poetry-runtime.log
# Private data replaced by "***"
$ poetry publish --repository nexus --username "***" --password "***" --skip-existing -vvv
Adding repository pypi-proxy (https://***/repository/pypi-proxy/simple) and setting it as primary
Deactivating the PyPI repository

Publishing *** (0.4.3) to nexus
- Uploading ***-0.4.3-py3-none-any.whl 0%[urllib3:urllib3.connectionpool] Starting new HTTPS connection (1): ***:443
- Uploading ***-0.4.3-py3-none-any.whl 100%[urllib3:urllib3.connectionpool] https://***:443 "POST /repository/***/ HTTP/1.1" 400 None
- Uploading ***-0.4.3-py3-none-any.whl FAILED

Stack trace:

1  venv/lib/python3.13/site-packages/poetry/publishing/uploader.py:252 in _upload_file
    250│                     bar.display()
    251│                 else:
  → 252│                     resp.raise_for_status()
    253│ 
    254│             except requests.RequestException as e:

HTTPError

400 Client Error: ***/packages/***/0.4.3/***-0.4.3-py3-none-any.whl cannot be updated for url: https://***/repository/***/

at venv/lib/python3.13/site-packages/requests/models.py:1026 in raise_for_status
    1022│                 f"{self.status_code} Server Error: {reason} for url: {self.url}"
    1023│             )
    1024│ 
    1025│         if http_error_msg:
  → 1026│             raise HTTPError(http_error_msg, response=self)
    1027│ 
    1028│     def close(self):
    1029│         """Releases the connection back to the pool. Once this method has been
    1030│         called the underlying ``raw`` object must not be accessed again.

The following error occurred when trying to handle this error:


Stack trace:

11  venv/lib/python3.13/site-packages/cleo/application.py:327 in run
     325│ 
     326│             try:
   → 327│                 exit_code = self._run(io)
     328│             except BrokenPipeError:
     329│                 # If we are piped to another process, it may close early and send a

10  venv/lib/python3.13/site-packages/poetry/console/application.py:260 in _run
     258│ 
     259│             try:
   → 260│                 exit_code = super()._run(io)
     261│             except PoetryRuntimeError as e:
     262│                 io.write_error_line("")

 9  venv/lib/python3.13/site-packages/cleo/application.py:431 in _run
     429│             io.input.interactive(interactive)
     430│ 
   → 431│         exit_code = self._run_command(command, io)
     432│         self._running_command = None
     433│ 

 8  venv/lib/python3.13/site-packages/cleo/application.py:473 in _run_command
     471│ 
     472│         if error is not None:
   → 473│             raise error
     474│ 
     475│         return terminate_event.exit_code

 7  venv/lib/python3.13/site-packages/cleo/application.py:457 in _run_command
     455│ 
     456│             if command_event.command_should_run():
   → 457│                 exit_code = command.run(io)
     458│             else:
     459│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

 6  venv/lib/python3.13/site-packages/cleo/commands/base_command.py:117 in run
     115│         io.input.validate()
     116│ 
   → 117│         return self.execute(io) or 0
     118│ 
     119│     def merge_application_definition(self, merge_args: bool = True) -> None:

 5  venv/lib/python3.13/site-packages/cleo/commands/command.py:61 in execute
      59│ 
      60│         try:
   →  61│             return self.handle()
      62│         except KeyboardInterrupt:
      63│             return 1

 4  venv/lib/python3.13/site-packages/poetry/console/commands/publish.py:101 in handle
      99│         )
     100│ 
   → 101│         publisher.publish(
     102│             self.option("repository"),
     103│             self.option("username"),

 3  venv/lib/python3.13/site-packages/poetry/publishing/publisher.py:86 in publish
      84│         )
      85│ 
   →  86│         self._uploader.upload(
      87│             url,
      88│             cert=resolved_cert,

 2  venv/lib/python3.13/site-packages/poetry/publishing/uploader.py:102 in upload
     100│ 
     101│         with session:
   → 102│             self._upload(session, url, dry_run, skip_existing)
     103│ 
     104│     def post_data(self, file: Path) -> dict[str, Any]:

 1  venv/lib/python3.13/site-packages/poetry/publishing/uploader.py:178 in _upload
     176│     ) -> None:
     177│         for file in self.files:
   → 178│             self._upload_file(session, url, file, dry_run, skip_existing)
     179│ 
     180│     def _upload_file(

UploadError

HTTP Error 400: ***/packages/***/0.4.3/***-0.4.3-py3-none-any.whl cannot be updated | b'\n<!DOCTYPE html>\n<html lang="en">\n<head>\n  <title>400 - Sonatype Nexus Repository\n  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\n\n\n  <link rel="icon" type="image/png" href="../../static/rapture/resources/safari-favicon-32x32.png?3.75.1-01" sizes="32x32">\n  <link rel="mask-icon" href="../../static/rapture/resources/favicon-white.svg?3.75.1-01" color="#00bb6c">\n  <link rel="icon" type="image/png" href="../../static/rapture/resources/favicon.svg?3.75.1-01" sizes="16x16">\n\n  <link rel="stylesheet" type="text/css" href="../../static/css/nexus-content.css?3.75.1-01"/>\n\n<body>\n<div class="nexus-header">\n  <a href="../..">\n    <div class="product-logo">\n      <img src="../../static/rapture/resources/nxrm-reverse-icon.png?3.75.1-01" alt="Product logo"/>\n    \n    <div class="product-id">\n      <div class="product-id__line-1">\n        <span class="product-name">Sonatype Nexus Repository\n      \n      <div class="product-id__line-2">\n        <span class="product-spec">OSS 3.75.1-01\n      \n    \n  \n\n\n<div class="nexus-body">\n  <div class="content-header">\n    <img src="../../static/rapture/resources/icons/x32/exclamation.png?3.75.1-01" alt="Exclamation point" aria-role="presentation"/>\n    <span class="title">Error 400\n    <span class="description">Bad Request\n  \n  <div class="content-body">\n    <div class="content-section">\n      ***/packages/***/0.4.3/***-0.4.3-py3-none-any.whl cannot be updated\n    \n  \n\n\n\n\n'

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/publishingRelated to PyPI/PEP 503 publishingkind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions