spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix: resolve GitHub release asset API URL for private repo preset and workflow downloads

Open lselvar opened this issue 5 months ago • 0 comments

Summary

  • Extends the private-repo GitHub release asset fix from #2792 (extensions) to cover presets and workflows
  • For private/SSO repos, browser release URLs (https://github.com/<owner>/<repo>/releases/download/<tag>/<asset>) redirect to an HTML/SSO page instead of the asset, causing BadZipFile / download failures
  • Extracts the shared resolution logic into a reusable resolve_github_release_asset_api_url utility in _github_http.py

Fix — four download paths are now covered

PresetCatalog.download_pack (catalog-based preset install):

  • Resolves browser release URLs to REST API asset URLs before downloading the ZIP

preset add --from <url> (direct URL preset install):

  • Same resolution applied before downloading the ZIP

workflow add <url> (direct URL workflow install):

  • Same resolution applied before downloading the workflow YAML

workflow add <id> (catalog-based workflow install):

  • Same resolution applied before downloading the workflow YAML from the catalog url

Other URLs: existing behavior unchanged.

Implementation

A new shared resolve_github_release_asset_api_url(download_url, open_url_fn, timeout) function in _github_http.py contains the resolution logic. PresetCatalog delegates to it via a _resolve_github_release_asset_api_url method (same pattern as ExtensionCatalog). The __init__.py download paths import and call it directly.

Test plan

  • [ ] Run focused test suite:
    UV_NATIVE_TLS=true SSL_CERT_FILE=/opt/homebrew/etc/openssl@3/cert.pem UV_DEFAULT_INDEX=https://pypi.org/simple PYTHONPATH=src uv run --extra test pytest tests/test_presets.py -k 'download_pack'
    
    Expected: 2 passed
  • [ ] Run full preset and workflow test suite:
    UV_NATIVE_TLS=true SSL_CERT_FILE=/opt/homebrew/etc/openssl@3/cert.pem UV_DEFAULT_INDEX=https://pypi.org/simple PYTHONPATH=src uv run --extra test pytest tests/test_presets.py tests/test_workflows.py tests/test_github_http.py
    
    Expected: all passing
  • [ ] Verify specify preset add works for presets hosted on a private GitHub repo using browser release URLs
  • [ ] Verify specify preset add --from <url> works with a GitHub release asset URL from a private repo
  • [ ] Verify specify workflow add <id> works for catalog workflows hosted on a private GitHub repo
  • [ ] Verify specify workflow add <url> works with a GitHub release asset URL from a private repo

AI disclosure: This PR was developed with Claude Code assistance.

🤖 Generated with Claude Code

lselvar avatar Jun 04 '26 20:06 lselvar