can1357/oh-my-pi · error · AIError.OAuthError
failed to unmarshal LoadCodeAssistResponse: ${result.summary
Error message
failed to unmarshal LoadCodeAssistResponse: ${result.summary} What it means
parseLoadCodeAssistResponse validates the body of Google Cloud Code Assist's loadCodeAssist endpoint against an ArkType-style schema (currentTier, paidTier, allowedTiers, ineligibleTiers, cloudaicompanionProject). If the payload does not conform, this provisioning OAuthError includes the schema error summary. The login flow cannot determine account tiers or project without a well-formed response.
Source
Thrown at packages/ai/src/registry/oauth/google-antigravity.ts:97
type OperationError = typeof operationErrorSchema.infer;
const onboardUserResponseSchema = type({
"@type": "string",
"cloudaicompanionProject?": "string",
});
const onboardOperationSchema = type({
"name?": "string",
"done?": "boolean",
"error?": operationErrorSchema.or("null"),
"response?": onboardUserResponseSchema.or("null"),
});
type OnboardOperation = typeof onboardOperationSchema.infer;
function parseLoadCodeAssistResponse(payload: unknown): LoadCodeAssistResponse {
const result = loadCodeAssistResponseSchema(payload);
if (result instanceof type.errors) {
throw new AIError.OAuthError(`failed to unmarshal LoadCodeAssistResponse: ${result.summary}`, {
kind: "provisioning",
provider: PROVIDER,
});
}
return result;
}
function parseOnboardOperation(payload: unknown): OnboardOperation {
const result = onboardOperationSchema(payload);
if (result instanceof type.errors) {
throw new AIError.OAuthError(`failed to unmarshal OnboardUser operation: ${result.summary}`, {
kind: "provisioning",
provider: PROVIDER,
});
}
return result;
}
View on GitHub (pinned to 9690622007)
Solutions
- Read result.summary in the message to see exactly which field failed validation.
- Update the library/package to the latest version in case Google changed the loadCodeAssist response shape.
- Log the raw response payload from loadCodeAssist and compare against the expected schema fields.
- Retry the login later if Google is mid-rollout; check provider status pages.
- Ensure no proxy/corporate gateway is rewriting the endpoint response.
Example fix
// before: assume shape, crash on drift
const data = await response.json();
return data as LoadCodeAssistResponse;
// after: surface the schema summary and raw payload for diagnosis
const result = loadCodeAssistResponseSchema(await response.json());
if (result instanceof type.errors) {
throw new Error(`loadCodeAssist shape changed: ${result.summary}`);
} Defensive patterns
Strategy: try-catch
Type guard
function looksLikeLoadCodeAssist(p: unknown): boolean {
if (typeof p !== "object" || p === null) return false;
const o = p as Record<string, unknown>;
return "allowedTiers" in o || "cloudaicompanionProject" in o || "currentTier" in o || "paidTier" in o;
} Try / catch
try {
const project = await discoverProject(accessToken);
} catch (err) {
if (err instanceof AIError.OAuthError && String(err.message).startsWith("failed to unmarshal LoadCodeAssistResponse")) {
// schema mismatch — update library or inspect raw payload; retry once in case of transient drift
await Bun.sleep(1000);
const project = await discoverProject(accessToken);
} else {
throw err;
}
} Prevention
- Keep the package updated — Google can change the v1internal loadCodeAssist shape at any time.
- Exclude the daily-cloudcode-pa.googleapis.com endpoint from response-rewriting proxies.
- Log the raw 200 body (redacted) when schema validation fails to diagnose drift quickly.
- Treat this as an API-contract problem, not a credentials problem — re-login won't help.
When it happens
Trigger: postLoadCodeAssist receives HTTP 200 JSON that fails loadCodeAssistResponseSchema — e.g. allowedTiers present but not an array of {id} objects, currentTier of wrong shape, an error envelope, or Google changing the v1internal response shape.
Common situations: Google rolling out an API shape change to the internal daily-cloudcode-pa endpoint; a proxy or captive portal returning HTML/JSON that parses but has the wrong fields; region-restricted accounts receiving an alternate payload; library version lagging behind a Google-side schema update.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- failed to unmarshal OnboardUser operation: ${result.summary}
- ${ineligibility.reasonMessage}${validation}
- Antigravity credentials missing projectId
- Kilo device authorization response missing required fields
- Auth broker response failed schema validation
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/82f62dca05ab8790.
Report an issue: GitHub.