Skip to content

Telemetry disabled by overzealous GHES host detection on non-GitHub API requests #13402

@williammartin

Description

@williammartin

Problem

The telemetryDisablerTransport in api/http_client.go:165-170 checks every outgoing HTTP request with ghauth.IsEnterprise(host). If the host is not github.com, it calls telemetryDisabler.Disable(), which permanently disables telemetry for the entire CLI invocation.

func (t telemetryDisablerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
    if ghauth.IsEnterprise(getHost(req)) {
        t.telemetryDisabler.Disable()
    }
    return t.wrappedTransport.RoundTrip(req)
}

Several commands make legitimate HTTP requests to non-GitHub hosts through the factory HTTP client, triggering this check incorrectly.

Affected commands

Command Non-GitHub Host How
gh cs ports forward/list/visibility global.rel.tunnels.api.visualstudio.com Dev-tunnels API for port management
gh cs ssh global.rel.tunnels.api.visualstudio.com Dev-tunnels API for SSH tunnel
gh cs logs global.rel.tunnels.api.visualstudio.com Dev-tunnels API for log streaming
gh cs jupyter global.rel.tunnels.api.visualstudio.com Dev-tunnels API for Jupyter forwarding
gh cs rebuild global.rel.tunnels.api.visualstudio.com Dev-tunnels API for rebuild connection
gh api <full-url> Any host User can pass arbitrary URLs
gh attestation download/verify/inspect Bundle URLs Fetches attestation bundles directly
gh extension install/upgrade Release asset URLs Downloads from asset.APIURL

How to reproduce

GH_TELEMETRY=log gh cs ports forward 3000:3000
# ctrl+c after ports are forwarded (requires signal handler fix from #13401)
# Output: "Telemetry payload: none"

Impact

All codespace tunnel commands produce zero telemetry even for github.com users. The gh api command also loses telemetry whenever a user passes a full non-GitHub URL.

Possible fixes

  1. Allowlist known non-GitHub hosts - skip the enterprise check for known hosts like visualstudio.com
  2. Only check on GitHub API requests - only run the enterprise check when the request is to a host that looks like a GitHub API endpoint
  3. Check the configured host instead of request host - the intent is to detect GHES users, which is already done by mightBeGHESUser() at startup. The transport-level check could be removed or narrowed to only trigger on hosts that match the configured GH_HOST or auth hosts

References

  • api/http_client.go:160-170 - telemetryDisablerTransport
  • internal/ghcmd/cmd.go:88 - mightBeGHESUser() (startup check)
  • internal/ghcmd/cmd.go:103-104 - telemetryService.Disable() (startup disable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorspriority-3Affects a small number of users or is largely cosmetic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions