apm icon indicating copy to clipboard operation
apm copied to clipboard

[BUG] Private GitHub subdirectory installs bypass credential-aware persistent cache

Open DaveMeadAdjust opened this issue 3 months ago • 0 comments

Description

Persistent caching of a private GitHub subdirectory package bypasses APM's credential fallback. The cache attempt is forced through the anonymous GitHub environment, fails authentication, emits a misleading filter-v2 warning, and is discarded. Installation then succeeds through the normal authenticated download path.

Tested with APM 0.28.0 and current main (0.29.0) on macOS arm64.

Reproduction

  1. Create a private GitHub repository containing an installable APM package in a subdirectory.
  2. Confirm that an HTTPS Git clone succeeds non-interactively through the configured credential helper.
  3. Install the subdirectory package:
apm install --target skills OWNER/PRIVATE_REPO/path/to/package#TAG

APM emits:

Partial clone (--filter=blob:none) failed for https://github.com/OWNER/PRIVATE_REPO; retrying with full bare clone. Server may not support filter v2.

Installation succeeds through a later path, but apm cache info reports no cached Git repository/checkout for the package. Installing several subdirectory packages repeats the same failed cache attempt and warning.

Root cause evidence

The same filtered bare clone succeeds when normal Git credential helpers are available.

In current main, GitHubPackageDownloader._cache_git_env() chooses build_public_github_anonymous_git_env() for github.com before repository privacy is known. That environment suppresses credential helpers and retains GIT_ASKPASS=echo. GitCache._ensure_bare_repo() interprets every partial-clone CalledProcessError as possible filter-v2 incompatibility and retries a full clone with the same anonymous environment. Both attempts fail authentication; the downloader catches the cache exception and continues through its normal authenticated path.

Removing GIT_ASKPASS from the anonymous cache environment changes the low-level error to:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

This demonstrates an authentication-path failure, not filter-v2 incompatibility.

Expected behavior

  • After an anonymous cache attempt receives an authentication-equivalent failure, retry the persistent-cache operation through APM's existing credential resolution/fallback path.
  • Only describe filter-v2 incompatibility when the failure supports that diagnosis; otherwise preserve an accurate sanitized diagnostic.
  • Keep credentials out of argv, logs, persisted remote URLs, and cache keys.

Impact

Installation remains functional, but private subdirectory packages cannot benefit from the persistent Git cache. Catalog operations repeat unnecessary network work and emit misleading warnings.

DaveMeadAdjust avatar Aug 28 '26 21:08 DaveMeadAdjust