{"record":{"id":"68589c3c7a222256","repo":"stablyai/orca","slug":"invalid-accounts-snapshot-from-host","errorCode":null,"errorMessage":"Invalid accounts snapshot from host","messagePattern":"Invalid accounts snapshot from host","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mobile/src/components/accounts-snapshot.ts","lineNumber":233,"sourceCode":"          message: 'Inactive Codex limits use the wrong provider identity',\n          path: ['rateLimits', 'inactiveCodexAccounts', index, 'rateLimits', 'provider']\n        })\n      }\n    }\n  })\n\nexport type RateLimitWindow = z.infer<typeof RateLimitWindowSchema>\nexport type ProviderRateLimits = z.infer<typeof ProviderRateLimitsSchema>\nexport type InactiveAccountUsage = z.infer<typeof InactiveAccountUsageSchema>\nexport type RateLimitRuntimeTarget = z.infer<typeof RateLimitRuntimeTargetSchema>\nexport type ClaudeAccountSummary = z.infer<typeof ClaudeAccountSummarySchema>\nexport type CodexAccountSummary = z.infer<typeof CodexAccountSummarySchema>\nexport type AccountsSnapshot = z.infer<typeof AccountsSnapshotSchema>\n\nexport function decodeAccountsSnapshot(value: unknown): AccountsSnapshot {\n  const result = AccountsSnapshotSchema.safeParse(value)\n  if (!result.success) {\n    throw new Error('Invalid accounts snapshot from host')\n  }\n  return result.data\n}\n","sourceCodeStart":215,"sourceCodeEnd":237,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/components/accounts-snapshot.ts#L215-L237","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Align mobile and host versions — re-check the AccountsSnapshotSchema against the host's published shape.","Capture the raw value and run it through the schema in isolation to see the Zod issue list.","If a field was legitimately added, extend AccountsSnapshotSchema (use .passthrough() where appropriate) and ship both sides.","Log the safeParse error (currently discarded) to diagnose — see exampleFix."],"exampleFix":"// before\nconst result = AccountsSnapshotSchema.safeParse(value)\nif (!result.success) {\n  throw new Error('Invalid accounts snapshot from host')\n}\n\n// after — surface the Zod issues for diagnosis (keep message stable for callers)\nconst result = AccountsSnapshotSchema.safeParse(value)\nif (!result.success) {\n  console.warn('accounts snapshot parse failed:', result.error.issues)\n  throw new Error('Invalid accounts snapshot from host')\n}","handlingStrategy":"validation","validationCode":"// Validate at the trust boundary; log Zod issues on failure\nexport function decodeAccountsSnapshot(value: unknown): AccountsSnapshot {\n  const result = AccountsSnapshotSchema.safeParse(value)\n  if (!result.success) {\n    console.warn('Invalid accounts snapshot:', result.error.issues)\n    throw new Error('Invalid accounts snapshot from host')\n  }\n  return result.data\n}","typeGuard":"function isAccountsSnapshot(value: unknown): value is AccountsSnapshot {\n  return AccountsSnapshotSchema.safeParse(value).success\n}","tryCatchPattern":"try {\n  const snapshot = decodeAccountsSnapshot(raw)\n} catch (err) {\n  // show a generic 'accounts data unavailable' UI; log full Zod issues for debugging\n  setAccountsError('Accounts data unavailable. Update the host and retry.')\n}","preventionTips":["Keep mobile and host versions aligned when the wire format changes.","Use .passthrough() on schemas so additive host fields do not break older mobile builds.","Never discard safeParse error issues in production — at minimum warn-log them."],"tags":["mobile","zod","validation","schema","accounts","wire-format"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}