Poetry: Return a non-zero exit code when publishing to a repository fails

Created on 20 Jun 2018  路  7Comments  路  Source: python-poetry/poetry

Context: Using Poetry in Build (CI/CD) systems.
While using Poetry to upload a wheel file to Sonatype Nexus repository, Repository throws a 400 error if the wheel file with the same version is already available in the repository.

Example:
poetry publish $private_nexus_url --build

  1. Builds a wheel file _my_wheel_file_0.1.0_
  2. Uploads the wheel file to Nexus Repository => Version on Nexus: my_wheel_file_0.1.0

Run again without updating the version, i.e the project's version is still 0.1.0
poetry publish $private_nexus_url --build

  1. Builds a wheel file _my_wheel_file_0.0.1_
  2. Tries to upload the wheel file _my_wheel_file_0.0.1_ to Nexus Repository and returns an error message.
  3. "poetry publish" fails silently by displaying the error message.

Error message:

[HTTPError]                                                      
 400 Client Error: Repository does not allow updating assets: pypi-internal
 or url: <private repository url>   

Improvement/Bug:
In the context of CI/CD systems, a non-zero exit code along with error message is required else the build systems fail silently without uploading the latest artifact.
Exit with a non zero code along with error message

Note: We could configure Nexus to allow republishing the same artifact version again.

Bug Publishing

Most helpful comment

Publishing with wrong credentials ends up in the same behavior

All 7 comments

Just curious: Do you still see this behavior with the latest version of Poetry?

@nchammas Yes, In poetry 0.11.4, still see the same behavior.

Publishing with wrong credentials ends up in the same behavior

same thing in last version :

In [6]: subprocess.check_output('poetry --version', shell=True).decode()                                                                                                                          
Out[6]: 'Poetry 0.12.6\n'                                                                                                                                                                         

In [7]: subprocess.check_call('poetry publish --username=wrong_username_茅霉$d --password=mokmokmo', shell=True)                                                                                              

Publishing aaaaa (0.1.0) to PyPI
Out[7]: 0  

should be labeled as a bug since it's definitely not the expected behavior

@nchammas yes, this behavior exists on 0.12.7.

This should be fixed in commit 903514060748496f9c87513ba7fb33ed29158325. It will be released in the next bugfix version.

Version 0.12.12 has just been released!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ambv picture ambv  路  3Comments

alexlatchford picture alexlatchford  路  3Comments

probablykasper picture probablykasper  路  3Comments

etijskens picture etijskens  路  3Comments

tonysyu picture tonysyu  路  3Comments