Skip to content

Installer and self-update ignore token env vars for GitHub release lookup #1582

@ErrevsSungam

Description

@ErrevsSungam

Summary

I cannot reliably install or update APM while connected through my company VPN, because APM does the GitHub releases/latest lookup anonymously even when I provide GITHUB_TOKEN or GITHUB_APM_PAT.

That means APM can fail on GitHub's shared anonymous/IP-based quota even though gh auth status is healthy and my authenticated GitHub API quota is not exhausted.

Observed with APM CLI 0.14.0.

Symptom

With the anonymous GitHub API quota exhausted:

export GITHUB_TOKEN="$(gh auth token)"
curl -sSL https://aka.ms/apm-unix | sh

can fail with:

Error: Invalid API response received
GitHub API Error:
API rate limit exceeded for .

The authenticated quota can still be healthy at the same time:

gh api rate_limit --jq '.resources.core'

What seems to be happening

In install.sh, the token env vars are resolved before release lookup, but APM still makes the first releases/latest request without auth:

  • install.sh resolves GITHUB_APM_PAT / GITHUB_TOKEN into AUTH_HEADER_VALUE.
  • The first https://api.github.com/repos/$APM_REPO/releases/latest call is made without that header.
  • The script only retries with auth for curl failure, empty response, or "Not Found".
  • A GitHub rate-limit response is valid JSON but has no tag_name, so the installer exits as Invalid API response received.

apm self-update appears to have the same issue one step earlier: it calls get_latest_version_from_github() before running the installer, and that helper also requests releases/latest without auth headers.

Expected behavior

If GITHUB_APM_PAT or GITHUB_TOKEN is set, APM should not start with an anonymous release lookup. It should either:

  • use it for the first releases/latest request, or
  • retry with auth when GitHub returns an anonymous rate-limit response.

Workaround

Pin the version using authenticated gh, which lets the installer skip releases/latest:

VERSION="$(gh api repos/microsoft/apm/releases/latest --jq .tag_name)"
curl -sSL https://aka.ms/apm-unix | VERSION="$VERSION" GITHUB_TOKEN="$(gh auth token)" sh

Related context

I searched existing issues/PRs and did not find this exact case already tracked.

Related but distinct:

Small repro note

This form does not pass the token to the installer process:

GITHUB_TOKEN="$(gh auth token)" curl -sSL https://aka.ms/apm-unix | sh

The env assignment only applies to curl, not the sh process. The repro above uses export so the installer receives the token.

Metadata

Metadata

Assignees

Labels

area/cliCLI command surface, flags, help text (cross-cutting).priority/highShips in current or next milestonestatus/acceptedDirection approved, safe to start work.status/shepherdingActively being driven by an APM shepherd runstatus/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).theme/securitySecure by default. Content scanning, lockfile integrity, MCP trust boundaries.type/bugSomething does not work as documented.

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions