earendil-works/pi · error · Error
Invalid xAI OAuth response field: ${field}
Error message
Invalid xAI OAuth response field: ${field} What it means
Error "Invalid xAI OAuth response field: ${field}" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/auth/oauth/xai.ts:36
type OAuthHttpResponse = {
ok: boolean;
status: number;
body: JsonObject;
};
type XaiDeviceCode = {
deviceCode: string;
userCode: string;
verificationUri: string;
verificationUriComplete?: string;
intervalSeconds?: number;
expiresInSeconds: number;
};
function requiredString(body: JsonObject, field: string): string {
const value = body[field];
if (typeof value !== "string" || value.length === 0) {
throw new Error(`Invalid xAI OAuth response field: ${field}`);
}
return value;
}
function positiveNumber(body: JsonObject, field: string): number {
const value = body[field];
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
throw new Error(`Invalid xAI OAuth response field: ${field}`);
}
return value;
}
// The verification URI is opened in the user's browser; force it to be an https URL
// so a malicious response cannot make `open` launch something else.
function validateVerificationUri(raw: string): string {
let url: URL;
try {
url = new URL(raw);View on GitHub (pinned to 4af9d21d3b)
Solutions
- Inspect the xAI OAuth response for the named field; retry or update parsing.
When it happens
Trigger: Thrown at packages/ai/src/auth/oauth/xai.ts:36 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/4dd6f04b98f6f2b2.
Report an issue: GitHub.