Skip to content

fix: do not duplicate credentials already present in the url - #11271

Open
umutKaracelebi wants to merge 1 commit into
python-poetry:mainfrom
umutKaracelebi:fix/authenticated-url-credentials
Open

umutKaracelebi wants to merge 1 commit into
python-poetry:mainfrom
umutKaracelebi:fix/authenticated-url-credentials

Conversation

@umutKaracelebi

Copy link
Copy Markdown

Resolves: #11268

Authenticator.authenticated_url() writes the credentials in front of parsed.netloc, but the netloc of a url that already carries credentials contains them, so the result had two userinfo parts (https://alice:token@alice:token@example.org/simple/). Strip any userinfo from the netloc before adding the credentials back.

  • Added tests for changed code.
  • Updated documentation for changed code. — no documentation change needed, authenticated_url() is an internal helper and its behaviour is unchanged for urls without credentials.

pytest tests/utils/test_authenticator.py -> 79 passed, the new test_authenticated_url_does_not_duplicate_credentials_from_url fails without the change. pytest tests/utils -> 419 passed, 27 skipped. ruff check, ruff format --check and mypy are clean on the changed files.

Prepared with AI assistance.

The netloc of a url that carries credentials includes them, so
`authenticated_url()` produced two userinfo parts, e.g.
`https://alice:token@alice:token@example.org/simple/`. Strip the
userinfo before adding the credentials back.

Refs: python-poetry#11268
Copilot AI balanced review requested due to automatic review settings November 24, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit 0025f36

#11268 Authenticator.authenticated_url doubles credentials already embedded in the source URL · 2 of 2 met

# Requirement Status Notes
1 Prevent authenticated_url() from duplicating credentials already embedded in the source URL. ✅ Met The existing userinfo is removed from parsed.netloc before credentials are added back.
2 Add a regression test in test_authenticator.py. ✅ Met The new test checks that a URL with embedded credentials is returned without duplicate userinfo.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authenticator.authenticated_url doubles credentials already embedded in the source URL

2 participants