Python Remote URL construction incorrectly appends `/simple/`, breaking Gitea PyPI integration

未关闭
#868 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

Start by tracing the Python remote URL construction logic that appends /simple/; no source file or test path is identified in the issue. Reproduce both Gitea URL cases, then add coverage showing that a complete /simple/ URL is requested unchanged and that the resulting requests no longer return 404.

由索引模型根据 Issue 内容生成。

描述

Issue

Version

  • Pulp Operator: v1.0.0

Describe the bug

The pulp-python plugin unconditionally appends the /simple/ suffix to the url provided for a Python remote. This behavior is hardcoded and assumes the remote URL points to a repository root that needs /simple/ added to reach the PEP 503 index.

This assumption breaks compatibility with PyPI-compatible registries like Gitea, where the complete, non-modifiable simple index URL is already provided. The forced suffix leads to incorrect URL generation.

To Reproduce
* Gitea Instance with a PyPI Registry: e.g., https://gitea.example.xyz
* Target Gitea PyPI URL: https://gitea.example.xyz/api/packages/example/pypi/simple/

  • Attempt 1: Provide the full, correct URL ending in /simple/

      pulp python remote create \
          --name gitea-remote-full \
          --url https://gitea.example.xyz/api/packages/example/pypi/simple/ \
          --username <user> \
          --password <pass>
      
      pulp python repository create --name test-repo-1
      pulp python repository sync --name test-repo-1 --remote gitea-remote-full
    
  • Attempt 2: Provide the URL without the /simple/ suffix

      pulp python remote create \
          --name gitea-remote-base \
          --url https://gitea.example.xyz/api/packages/example/pypi \
          --username <user> \
          --password <pass>
    
      pulp python repository create --name test-repo-2
      pulp python repository sync --name test-repo-2 --remote gitea-remote-base
    

Pulp's automatic suffixing logic causes 404 errors in both scenarios.

  1. In Attempt 1, Pulp appends an extra /simple/, resulting in a "double suffix":

    • URL requested: https://gitea.example.xyz/api/packages/example/pypi/simple/simple/
    • Result: 404 Not Found.
  2. In Attempt 2, Pulp strips the last path segment (/pypi) and appends /simple/, also forming an incorrect URL:

    • URL requested: https://gitea.example.xyz/api/packages/example/simple/
    • Result: 404 Not Found.

Expected behavior
Pulp should respect the provided url for a Python remote. When a URL is provided, Pulp should either:
a. Use the URL as-is, without modification.
b. Check if the URL already ends with /simple/ and, if so, refrain from appending it again.

For the configuration in Attempt 1, Pulp should make requests directly to https://gitea.example.xyz/api/packages/example/pypi/simple/.

Additional context
This behavior makes it impossible to use Gitea as a PyPI remote source for Pulp. More broadly, it limits Pulp's compatibility with any PyPI-compliant repository that provides a full, unchangeable URL to its simple index and does not conform to the exact .../ -> .../simple/ transformation that Pulp enforces.

A fix should be relatively easy: Modify the URL construction logic to first check if url.endswith('/simple/'). If true, use the URL as-is

This would provide the necessary flexibility to integrate with a wider range of non-standard but popular PyPI-compatible endpoints like Gitea.

主要语言
Python
星标
49
派生
88
平均合并
1 天 10 小时
30 天内合并 PR
31

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pulp/pulp_python 的其他 Issue

查看 pulp/pulp_python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。