fix: rewrite helm index.yaml URLs post-parse to handle relative URLs #37

Merged
unkinben merged 1 commits from benvin/issue-33-helm-relative-url-rewrite into master 2026-05-02 01:22:17 +10:00
Owner

Closes #33

Summary

  • _merge_helm_indexes now parses each member's raw YAML first, then rewrites urls entries in-place via the new _rewrite_urls helper
  • Relative URLs (e.g. rancher-2.13.1.tgz) are prepended with {proxy_base}/api/v1/remote/{member_name}/
  • Absolute URLs matching base_url are rewritten to the proxy path (existing behaviour, now correct)
  • Absolute URLs with a different prefix are left unchanged
  • Removes the _helm.resolve_content raw-bytes detour from the virtual merge path; remote/helm.py is unchanged (still used for direct remote proxying)

Test plan

  • 278 unit tests pass (make test)
  • New TestRewriteUrls class covering relative, absolute-match, absolute-no-match, leading-slash, and multi-URL cases
  • New test_relative_urls_rewritten_to_proxy in TestMergeHelmIndexes
  • Updated test_first_member_wins_on_duplicate_name_and_version to assert on proxy remote name (not upstream hostname)
  • Live Docker test: Rancher index.yaml relative URLs rewritten correctly to http://localhost:8000/api/v1/remote/rancher-stable/rancher-2.14.1.tgz etc.
  • helm-all virtual (19 members) returns HTTP 200 with 395k-line merged index on cache miss
Closes #33 ## Summary - `_merge_helm_indexes` now parses each member's raw YAML first, then rewrites `urls` entries in-place via the new `_rewrite_urls` helper - **Relative URLs** (e.g. `rancher-2.13.1.tgz`) are prepended with `{proxy_base}/api/v1/remote/{member_name}/` - **Absolute URLs** matching `base_url` are rewritten to the proxy path (existing behaviour, now correct) - **Absolute URLs** with a different prefix are left unchanged - Removes the `_helm.resolve_content` raw-bytes detour from the virtual merge path; `remote/helm.py` is unchanged (still used for direct remote proxying) ## Test plan - [x] 278 unit tests pass (`make test`) - [x] New `TestRewriteUrls` class covering relative, absolute-match, absolute-no-match, leading-slash, and multi-URL cases - [x] New `test_relative_urls_rewritten_to_proxy` in `TestMergeHelmIndexes` - [x] Updated `test_first_member_wins_on_duplicate_name_and_version` to assert on proxy remote name (not upstream hostname) - [x] Live Docker test: Rancher `index.yaml` relative URLs rewritten correctly to `http://localhost:8000/api/v1/remote/rancher-stable/rancher-2.14.1.tgz` etc. - [x] `helm-all` virtual (19 members) returns HTTP 200 with 395k-line merged index on cache miss
unkinben added 1 commit 2026-05-01 23:45:01 +10:00
fix: rewrite helm index.yaml URLs post-parse to handle relative URLs
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
07595f0377
Raw byte replacement in _merge_helm_indexes only worked when the upstream
index contained absolute URLs matching base_url. Upstreams like Rancher use
relative URLs (e.g. rancher-2.13.1.tgz), which were left unrewritten,
causing Helm to construct a 404-producing URL against the virtual repo.

Now parses YAML first, then rewrites each entry's urls list:
- relative URL → prepend {proxy_base}/api/v1/remote/{member_name}/
- absolute URL matching base_url → replace prefix with proxy remote path
unkinben merged commit 624d858062 into master 2026-05-02 01:22:17 +10:00
unkinben deleted branch benvin/issue-33-helm-relative-url-rewrite 2026-05-02 01:22:17 +10:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/artifactapi#37