{"record":{"id":"7a6dc899fa46518c","repo":"different-ai/openwork","slug":"invalid-cloud-provider-sync-status","errorCode":null,"errorMessage":"Invalid cloud provider sync status.","messagePattern":"Invalid cloud provider sync status\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/app/lib/openwork-server.ts","lineNumber":73,"sourceCode":"  /** Machine-readable skip reason, e.g. \"missing_credentials\". */\n  reason: string;\n};\n\nexport type OpenworkCloudProviderSyncStatus = {\n  hasSession: boolean;\n  lastRun: { at: string | number; status: OpenworkCloudProviderSyncRun[\"status\"]; message?: string } | null;\n  providers: CloudImportedProvider[];\n  /** A managed engine reload is still owed: materialized providers are not served yet. */\n  reloadPending: boolean;\n  /** Den-granted providers the server sync skipped, each with a reason. */\n  skippedProviders: OpenworkCloudProviderSyncSkippedProvider[];\n};\n\nfunction parseCloudProviderSyncRun(value: unknown): OpenworkCloudProviderSyncRun {\n  if (!value || typeof value !== \"object\" || !(\"status\" in value)) throw new Error(\"Invalid cloud provider sync response.\");\n  const status = value.status;\n  if (status !== \"applied\" && status !== \"noop\" && status !== \"failed\" && status !== \"no_session\") {\n    throw new Error(\"Invalid cloud provider sync status.\");\n  }\n  const message = \"message\" in value && typeof value.message === \"string\" ? value.message : undefined;\n  return { status, message };\n}\n\nfunction parseCloudImportedProvider(value: unknown): CloudImportedProvider | null {\n  if (!value || typeof value !== \"object\") return null;\n  if (\n    !(\"cloudProviderId\" in value) || typeof value.cloudProviderId !== \"string\" ||\n    !(\"providerId\" in value) || typeof value.providerId !== \"string\" ||\n    !(\"sourceProviderId\" in value) || typeof value.sourceProviderId !== \"string\" ||\n    !(\"name\" in value) || typeof value.name !== \"string\" ||\n    !(\"modelIds\" in value) || !Array.isArray(value.modelIds) || !value.modelIds.every((item) => typeof item === \"string\")\n  ) return null;\n  return {\n    cloudProviderId: value.cloudProviderId,\n    providerId: value.providerId,\n    sourceProviderId: value.sourceProviderId,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/app/lib/openwork-server.ts#L55-L91","documentation":"After confirming a `status` field exists, parseCloudProviderSyncRun checks it against the allowed values: applied, noop, failed, no_session. Any other status string throws this error, protecting callers from handling an unrecognized sync outcome.","triggerScenarios":"The sync run response contains a `status` value outside the known set — a server upgrade introduced a new status (e.g. \"partial\"), or a localized/error payload coincidentally includes a status string.","commonSituations":"Client and Den server version skew after a server-side enum addition, mock/test server returning statuses the client doesn't know, or a different endpoint's payload being parsed by mistake.","solutions":["Log the unexpected status value to identify exactly what the server sent.","Update the client's allowed-status union to include the new server status and handle it.","Align client and server versions so enums match.","Verify the request hits the sync run endpoint, not another route."],"exampleFix":"// before\nif (status !== \"applied\" && status !== \"noop\" && status !== \"failed\" && status !== \"no_session\") {\n  throw new Error(\"Invalid cloud provider sync status.\");\n}\n// after: tolerate known-but-unhandled statuses explicitly\nconst KNOWN = [\"applied\", \"noop\", \"failed\", \"no_session\"] as const;\nif (!KNOWN.includes(status)) throw new Error(`Invalid cloud provider sync status: ${String(status)}`);","handlingStrategy":"validation","validationCode":"const body = await res.json();\nif (body && typeof body === \"object\" && \"status\" in body) {\n  const KNOWN = [\"applied\", \"noop\", \"failed\", \"no_session\"];\n  if (!KNOWN.includes(body.status)) console.warn(\"Server returned unknown sync status:\", body.status);\n}","typeGuard":"function isKnownSyncStatus(s: unknown): s is \"applied\" | \"noop\" | \"failed\" | \"no_session\" {\n  return s === \"applied\" || s === \"noop\" || s === \"failed\" || s === \"no_session\";\n}","tryCatchPattern":"try {\n  const run = await client.cloud.providerSync.run();\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"Invalid cloud provider sync status\")) {\n    // enum skew: pin client to matching server version and report the raw status\n    reportClientServerVersionSkew(err);\n  } else throw err;\n}","preventionTips":["Keep client and Den server deployed in lockstep so status enums match.","When adding server statuses, extend the client union in the same release.","Include the raw status value in the thrown message for diagnosis.","Test clients against mock servers that only emit known statuses."],"tags":["validation","api-response","cloud","enum-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}