github/copilot-sdk · error

missing GitHub token acquire request

Error message

missing GitHub token acquire request

What it means

Returned by gitHubTokenAdapter.GetToken when the JSON-RPC layer delivers a nil GitHubTokenAcquireRequest. The adapter cannot look up a provider without a registration ID, so it rejects the call immediately instead of panicking on a nil dereference.

Solutions

  1. Upgrade CLI and SDK to matching versions so the acquire request is always serialized with the payload.
  2. Check for a bug in the caller constructing the request; ensure the JSON-RPC params object is populated.
  3. Inspect the peer's logs to see why an empty request was dispatched.

Example fix

// before
adapter := &gitHubTokenAdapter{client: c} // nil requests surface as this error

// after
func (a *gitHubTokenAdapter) GetToken(req *rpc.GitHubTokenAcquireRequest) (rpc.GitHubTokenAcquireResult, error) {
    if req == nil {
        return nil, fmt.Errorf("missing GitHub token acquire request")
    }
    // proceed
    return a.GetTokenChecked(req)
}
Defensive patterns

Strategy: type-guard

Type guard

func validAcquireRequest(r *rpc.GitHubTokenAcquireRequest) bool { return r != nil && r.RegistrationID != "" }

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "missing GitHub token acquire request") {
        // peer sent empty payload; log and check protocol versions
    }
    return err
}

Prevention

When it happens

Trigger: The CLI server sends a github token acquire callback with a null/absent request payload, invoking gitHubTokenAdapter.GetToken(nil).

Common situations: Protocol/version mismatch where the peer sends an empty params object; a serialization bug on the CLI side; manually constructed RPC calls omitting the request body.

Related errors


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

Appendix: source

Thrown at go/client.go:2583

	operation.mutex.Lock()
	return func() {
		operation.mutex.Unlock()
		c.sessionOperationsMux.Lock()
		operation.users--
		if operation.users == 0 {
			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

View on GitHub (pinned to cd8cf15dc3)