stablyai/orca · error · Error

Invalid accounts snapshot from host

Error message

Invalid accounts snapshot from host

What it means

decodeAccountsSnapshot() runs the host-supplied accounts payload through a Zod schema (AccountsSnapshotSchema) and throws this fixed string when safeParse fails. It is the trust-boundary validator for the entire accounts/rate-limit data the host sends to mobile — any shape mismatch (missing field, wrong enum, out-of-range number) collapses to this single message.

Source

Thrown at mobile/src/components/accounts-snapshot.ts:233

          message: 'Inactive Codex limits use the wrong provider identity',
          path: ['rateLimits', 'inactiveCodexAccounts', index, 'rateLimits', 'provider']
        })
      }
    }
  })

export type RateLimitWindow = z.infer<typeof RateLimitWindowSchema>
export type ProviderRateLimits = z.infer<typeof ProviderRateLimitsSchema>
export type InactiveAccountUsage = z.infer<typeof InactiveAccountUsageSchema>
export type RateLimitRuntimeTarget = z.infer<typeof RateLimitRuntimeTargetSchema>
export type ClaudeAccountSummary = z.infer<typeof ClaudeAccountSummarySchema>
export type CodexAccountSummary = z.infer<typeof CodexAccountSummarySchema>
export type AccountsSnapshot = z.infer<typeof AccountsSnapshotSchema>

export function decodeAccountsSnapshot(value: unknown): AccountsSnapshot {
  const result = AccountsSnapshotSchema.safeParse(value)
  if (!result.success) {
    throw new Error('Invalid accounts snapshot from host')
  }
  return result.data
}

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Align mobile and host versions — re-check the AccountsSnapshotSchema against the host's published shape.
  2. Capture the raw value and run it through the schema in isolation to see the Zod issue list.
  3. If a field was legitimately added, extend AccountsSnapshotSchema (use .passthrough() where appropriate) and ship both sides.
  4. Log the safeParse error (currently discarded) to diagnose — see exampleFix.

Example fix

// before
const result = AccountsSnapshotSchema.safeParse(value)
if (!result.success) {
  throw new Error('Invalid accounts snapshot from host')
}

// after — surface the Zod issues for diagnosis (keep message stable for callers)
const result = AccountsSnapshotSchema.safeParse(value)
if (!result.success) {
  console.warn('accounts snapshot parse failed:', result.error.issues)
  throw new Error('Invalid accounts snapshot from host')
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate at the trust boundary; log Zod issues on failure
export function decodeAccountsSnapshot(value: unknown): AccountsSnapshot {
  const result = AccountsSnapshotSchema.safeParse(value)
  if (!result.success) {
    console.warn('Invalid accounts snapshot:', result.error.issues)
    throw new Error('Invalid accounts snapshot from host')
  }
  return result.data
}

Type guard

function isAccountsSnapshot(value: unknown): value is AccountsSnapshot {
  return AccountsSnapshotSchema.safeParse(value).success
}

Try / catch

try {
  const snapshot = decodeAccountsSnapshot(raw)
} catch (err) {
  // show a generic 'accounts data unavailable' UI; log full Zod issues for debugging
  setAccountsError('Accounts data unavailable. Update the host and retry.')
}

Prevention

When it happens

Trigger: The host returns an accounts snapshot that violates AccountsSnapshotSchema — e.g. a provider name outside the enum, a usedPercent > 100, a non-integer timestamp, or a renamed field after a wire-format change.

Common situations: Version skew: a newer host publishes fields the mobile schema rejects, an older host omits required fields, a manual edit to the schema's enum list, or a bug in the host serialization producing non-finite percentages.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/68589c3c7a222256. Report an issue: GitHub.