Skip to content

publishing succeeds when endpoint returns an HTTP 3xx #3600

Closed
@mawillcockson

Description

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Debian 10 "buster"

  • Poetry version: 1.1.4 and git

  • Link to a Gist with the contents of your pyproject.toml file: not applicable

tl;dr

a screenshot of a terminal showing the result of running the code snippet below, which is that twine fails and poetry appears to succeed

#!/bin/sh
set -eux
poetry new temp
cd temp && poetry build

export TWINE_USERNAME="invalid username"
export TWINE_PASSWORD="invalid password"
# Note the slash missing from the end of the url
export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy"
set +e
# twine raises an error as expected
twine upload --non-interactive dist/*
set -e

export POETRY_HTTP_BASIC_TEMP_USERNAME="${TWINE_USERNAME}"
export POETRY_HTTP_BASIC_TEMP_PASSWORD="${TWINE_PASSWORD}"
export POETRY_REPOSITORIES_TEMP_URL="${TWINE_REPOSITORY_URL}"
# poetry does not raise an error
poetry publish --repository temp --no-interaction -vvv

# Adding the slash causes poetry to return an expected error
export POETRY_REPOSITORIES_TEMP_URL="${POETRY_REPOSITORIES_TEMP_URL}/"
poetry publish --repository temp --no-interaction -vvv

Issue

I was trying to use poetry to upload packages to the PyPI Test instance, and couldn't figure out how poetry could report a successful publish without my packages showing up on test.pypi.org anywhere.

I was missing a / character at the end of the URL, and PyPI was returning an HTTP 308 redirect to the same URL, with the / at the end:

https://test.pypi.org/legacy 🠒 https://test.pypi.org/legacy/

This bug is reproducible with test URLs like https://httpbin.org/status/399

This may be related to #3198.

I'm very sorry, I haven't dug into this.

Solution / Workaround

poetry behaves as expected when the repository url is a valid PyPI Legacy Upload API endpoint.

In short, I was missing a / character at the end of the URL.

Metadata

Assignees

No one assigned

    Labels

    kind/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