earendil-works/pi · error · Error
Invalid Copilot token response fields
Error message
Invalid Copilot token response fields
What it means
Error "Invalid Copilot token response fields" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/auth/oauth/github-copilot.ts:338
const raw = await fetchJson(urls.copilotTokenUrl, {
headers: {
Accept: "application/json",
Authorization: `Bearer ${refreshToken}`,
...COPILOT_HEADERS,
},
signal,
});
if (!raw || typeof raw !== "object") {
throw new Error("Invalid Copilot token response");
}
const token = (raw as Record<string, unknown>).token;
const expiresAt = (raw as Record<string, unknown>).expires_at;
if (typeof token !== "string" || typeof expiresAt !== "number") {
throw new Error("Invalid Copilot token response fields");
}
return {
type: "oauth",
refresh: refreshToken,
access: token,
expires: expiresAt * 1000 - 5 * 60 * 1000,
enterpriseUrl: enterpriseDomain,
};
}
/**
* Refresh GitHub Copilot token
*/
async function refreshGitHubCopilotToken(
refreshToken: string,
enterpriseDomain: string | undefined,
signal: AbortSignal,View on GitHub (pinned to 4af9d21d3b)
Solutions
- Retry; update field parsing if the Copilot token response shape changed.
When it happens
Trigger: Thrown at packages/ai/src/auth/oauth/github-copilot.ts:338 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/79ad712458815f01.
Report an issue: GitHub.