can1357/oh-my-pi · error · AIError.OAuthError

failed to unmarshal OnboardUser operation: ${result.summary}

Error message

failed to unmarshal OnboardUser operation: ${result.summary}

What it means

parseOnboardOperation validates responses from Cloud Code Assist's onboardUser endpoint and its long-running operation polling (GET v1internal/{name}) against onboardOperationSchema (name, done, error, response with @type). A non-conforming payload throws this provisioning OAuthError with the schema summary. The Antigravity onboarding state machine cannot proceed on a malformed operation object.

Source

Thrown at packages/ai/src/registry/oauth/google-antigravity.ts:108

	"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;
}

function extractProjectId(payload: LoadCodeAssistResponse): string | undefined {
	const projectId = payload.cloudaicompanionProject;
	return projectId && projectId.length > 0 ? projectId : undefined;
}

function hasMessageField(payload: LoadCodeAssistResponse, field: "currentTier" | "paidTier"): boolean {
	return payload[field] !== undefined && payload[field] !== null;
}

function isFreeTierAllowed(payload: LoadCodeAssistResponse): boolean {
	return payload.allowedTiers?.some(tier => tier.id === FREE_TIER_ID) === true;

View on GitHub (pinned to 9690622007)

Solutions

  1. Inspect result.summary in the message to identify the mismatched field (most commonly the response '@type').
  2. Update to the latest library version in case the operation schema needs adjusting for a Google change.
  3. Retry onboarding later — if provisioning is stuck server-side, the poll loop may surface transient malformed payloads.
  4. Capture and log the raw operation JSON to compare with the schema and file/report the drift.
  5. Verify the account has Cloud Code Assist access; restricted accounts can receive alternate payloads.

Example fix

// before: blind cast of the operation
const op = (await res.json()) as OnboardOperation;

// after: validate and surface the summary
const result = onboardOperationSchema(await res.json());
if (result instanceof type.errors) {
  throw new Error(`onboardUser operation malformed: ${result.summary}`);
}
Defensive patterns

Strategy: try-catch

Type guard

function looksLikeOperation(p: unknown): boolean {
  if (typeof p !== "object" || p === null) return false;
  const o = p as Record<string, unknown>;
  return "done" in o || "name" in o || "@type" in o;
}

Try / catch

try {
  await onboardUser(context);
} catch (err) {
  if (err instanceof AIError.OAuthError && String(err.message).startsWith("failed to unmarshal OnboardUser operation")) {
    logger.error("onboardUser payload schema mismatch", { summary: String(err.message) });
    // surface to user; likely needs a library update for a Google API change
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: onboardUser or the operation-poll GET returns 200 JSON failing onboardOperationSchema — e.g. missing '@type' on the response sub-object, error/response fields of the wrong type, or Google altering the operation envelope; also occurs on every poll iteration until the operation completes.

Common situations: Google-side API shape drift on the v1internal operations endpoint; intermediate proxy mangling the payload; project provisioning stuck so repeated polls hit an unexpected payload; outdated library version predating a schema change.

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


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/02e51631b7ecac32. Report an issue: GitHub.