Skip to content

fix: support underscored repository names from env - #11061

Open
QIU-Guanzong wants to merge 2 commits into
python-poetry:mainfrom
QIU-Guanzong:qiu/fix-underscore-repository-auth
Open

QIU-Guanzong wants to merge 2 commits into
python-poetry:mainfrom
QIU-Guanzong:qiu/fix-underscore-repository-auth

Conversation

@QIU-Guanzong

Copy link
Copy Markdown

Summary

  • fall back to the environment-normalized repository name after an exact configured-name lookup
  • preserve exact-name precedence when both my_repo and my-repo are configured
  • cover credentials and certificate settings supplied through environment variables

Resolves: #7156

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code; this restores the documented environment-variable behavior without changing user-facing configuration.

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/poetry/utils/authenticator.py" line_range="384" />
<code_context>
             )
         else:
-            if name not in self.configured_repositories:
+            repository = self._get_configured_repository(name)
+            if repository is None:
                 return None
</code_context>
<issue_to_address>
**issue (broader_impact):** Publishing still resolves the repository URL with the original name in `Publisher.publish`, while this helper only normalizes the name for credentials and certificates. When `my-repo` is configured in the project and publishing is requested as `my_repo`, URL lookup raises `RuntimeError` before the new fallback is used.

**Triggers:** When a repository is configured with a hyphenated name and the publish command receives its underscored form.

**Suggested fix:** Use the same exact-then-underscored-to-hyphenated repository lookup for the publishing URL, or expose the resolved repository configuration to `Publisher.publish`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if the underscore-to-hyphen fallback resolves a repository incorrectly, the publisher could send stored credentials to the wrong repository endpoint. Reverting prevents future misrouting, but credentials already transmitted cannot be recalled.

Blocking findings: src/poetry/utils/authenticator.py:384


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

Comment thread src/poetry/utils/authenticator.py
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.

Credentials passed via POETRY_HTTP_BASIC_<repo>_USERNAME aren't found when the repository name contains an underscore _

1 participant