earendil-works/pi · error · Error

${response.status} ${response.statusText}: ${text}

Error message

${response.status} ${response.statusText}: ${text}

What it means

The Copilot models endpoint returned a non-OK HTTP status; the error embeds status, statusText, and the response body for diagnosis. Fires on expired tokens, rate limits, or upstream GitHub errors while listing models.

Solutions

  1. Check the HTTP status and body in the message; fix credentials or the endpoint.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/ai/src/auth/oauth/github-copilot.ts:201 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/10ac7eb443cfcd42. Report an issue: GitHub.

Appendix: source

Thrown at packages/ai/src/auth/oauth/github-copilot.ts:201

				Authorization: `Bearer ${copilotToken}`,
				...COPILOT_HEADERS,
				"X-GitHub-Api-Version": COPILOT_API_VERSION,
			},
		},
		signal,
		retryPolicy,
	);
	if (!response.ok) {
		throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);
	}
	return parseGitHubCopilotModelCatalog(await response.json(), allowPolicyFallback);
}

async function fetchJson(url: string, init: RequestInit): Promise<unknown> {
	const response = await fetch(url, init);
	if (!response.ok) {
		const text = await response.text();
		throw new Error(`${response.status} ${response.statusText}: ${text}`);
	}
	return response.json();
}

async function startDeviceFlow(domain: string, signal: AbortSignal): Promise<DeviceCodeResponse> {
	const urls = getUrls(domain);
	const data = await fetchJson(urls.deviceCodeUrl, {
		method: "POST",
		headers: {
			Accept: "application/json",
			"Content-Type": "application/x-www-form-urlencoded",
			"User-Agent": "GitHubCopilotChat/0.35.0",
		},
		body: new URLSearchParams({
			client_id: CLIENT_ID,
			scope: "read:user",
		}),
		signal,

View on GitHub (pinned to 4af9d21d3b)