github/copilot-sdk · error

unknown GitHub token provider registration ID

Error message

unknown GitHub token provider registration ID %q

What it means

Returned by gitHubTokenAdapter.GetToken when the request's RegistrationID does not match any provider previously registered on the Client via the GitHub token provider registry. The lookup under gitHubTokenProviders returns nil and the call fails with the offending ID quoted.

Solutions

  1. Register the provider with the exact RegistrationID the CLI sends before the token request arrives (RegisterGitHubTokenProvider).
  2. Log the set of registered IDs and compare with request.RegistrationID to spot stale/typo'd IDs.
  3. Re-register providers after any client restart or reconnect.
  4. Ensure the ID used at registration time is the one passed back by the registration API rather than a locally invented value.

Example fix

// before
c.RegisterGitHubTokenProvider("my-provider", providerFn) // CLI asks for id "github-main"

// after
id, err := c.RegisterGitHubTokenProvider(providerFn) // use returned canonical ID
if err != nil { log.Fatal(err) }
log.Printf("registered GitHub token provider id=%s", id)
Defensive patterns

Strategy: validation

Validate before calling

c.gitHubTokenProvidersMux.RLock()
_, ok := c.gitHubTokenProviders[wantedID]
c.gitHubTokenProvidersMux.RUnlock()
if !ok { return fmt.Errorf("provider %q not registered", wantedID) }

Try / catch

if err != nil && strings.Contains(err.Error(), "unknown GitHub token provider registration ID") {
    // re-register providers and retry once
}

Prevention

When it happens

Trigger: The CLI requests a GitHub token with a RegistrationID that was never registered (or was already unregistered) on the client, e.g. the provider map lookup returns nil.

Common situations: Registration ID typo or hardcoded stale ID; provider registered on a different Client instance; client restarted and registrations lost while the CLI still remembers the old ID; registration ID from an older session after reconnect.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/b8a0471bf26ce565. Report an issue: GitHub.

Appendix: source

Thrown at go/client.go:2589

			delete(c.sessionOperations, sessionID)
		}
		c.sessionOperationsMux.Unlock()
	}
}

type gitHubTokenAdapter struct {
	client *Client
}

func (a *gitHubTokenAdapter) GetToken(request *rpc.GitHubTokenAcquireRequest) (rpc.GitHubTokenAcquireResult, error) {
	if request == nil {
		return nil, fmt.Errorf("missing GitHub token acquire request")
	}
	a.client.gitHubTokenProvidersMux.RLock()
	provider := a.client.gitHubTokenProviders[request.RegistrationID]
	a.client.gitHubTokenProvidersMux.RUnlock()
	if provider == nil {
		return nil, fmt.Errorf("unknown GitHub token provider registration ID %q", request.RegistrationID)
	}

	result, err := provider(GitHubTokenProviderArgs{
		Host:      request.Host,
		SessionID: request.SessionID,
		Reason:    request.Reason,
	})
	if err != nil {
		return nil, err
	}
	if result != nil && result.Cancelled {
		return &rpc.GitHubTokenAcquireResultCancelled{}, nil
	}
	if result == nil || result.Token == nil {
		return nil, fmt.Errorf("GitHub token provider returned neither a token nor cancellation")
	}
	return &rpc.GitHubTokenAcquireResultToken{
		AccessToken: result.Token.AccessToken,

View on GitHub (pinned to cd8cf15dc3)