{"record":{"id":"b589fa1324f03f56","repo":"different-ai/openwork","slug":"invalid-resource-snapshot-payload","errorCode":"invalid_resource_snapshot_payload","errorMessage":"Resource snapshot response was invalid.","messagePattern":"Resource snapshot response was invalid\\.","errorType":"error_code","errorClass":"DenApiError","httpStatus":500,"severity":"warning","filePath":"apps/app/src/app/lib/den.ts","lineNumber":2996,"sourceCode":"\n    async getDesktopConfig(orgId?: string | null): Promise<DenDesktopConfig> {\n      const payload = await requestJson<unknown>(baseUrls, \"/v1/me/desktop-config\", {\n        method: \"GET\",\n        token,\n        organizationId: orgId,\n      });\n      return normalizeDenDesktopConfig(payload);\n    },\n\n    async getResourceSnapshot(orgId?: string | null): Promise<DenResourceSnapshot> {\n      const payload = await requestJson<unknown>(baseUrls, \"/v1/resources\", {\n        method: \"GET\",\n        token,\n        organizationId: orgId,\n      });\n      const snapshot = normalizeDenResourceSnapshot(payload);\n      if (!snapshot) {\n        throw new DenApiError(500, \"invalid_resource_snapshot_payload\", \"Resource snapshot response was invalid.\");\n      }\n      return snapshot;\n    },\n\n    async exchangeDesktopHandoff(grant: string): Promise<DenDesktopHandoffExchange> {\n      const payload = await requestJson<unknown>(baseUrls, \"/v1/auth/desktop-handoff/exchange\", {\n        method: \"POST\",\n        body: { grant },\n      });\n      return {\n        user: getUser(payload),\n        token: getToken(payload),\n        organization: getExchangeOrganization(payload),\n        connectEnabled: getExchangeConnectEnabled(payload),\n      };\n    },\n\n    async listOrgs(): Promise<{ orgs: DenOrgSummary[]; activeOrgId: string | null; activeOrgSlug: string | null; defaultOrgId: string | null }> {","sourceCodeStart":2978,"sourceCodeEnd":3014,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/app/lib/den.ts#L2978-L3014","documentation":"getResourceSnapshot normalizes the resource snapshot API response with normalizeDenResourceSnapshot; when normalization fails it throws a 500 DenApiError with code \"invalid_resource_snapshot_payload\". This ensures callers only ever receive a fully-shaped DenResourceSnapshot.","triggerScenarios":"The resource snapshot GET returns 2xx but the body cannot be normalized into a valid snapshot — partial data, schema drift, or a non-Den server responding.","commonSituations":"Server/client version mismatch after an API change, self-hosted deployments with older schemas, or proxies returning unexpected bodies.","solutions":["Log the raw snapshot payload and compare against the expected DenResourceSnapshot shape","Align server and client versions","Check for proxy interference and correct baseUrl configuration","Handle the error gracefully in UI (show snapshot unavailable)"],"exampleFix":"// before\nconst snapshot = await client.getResourceSnapshot(orgId);\nrender(snapshot);\n// after\ntry { render(await client.getResourceSnapshot(orgId)); }\ncatch (err) {\n  if (err instanceof DenApiError && err.code === \"invalid_resource_snapshot_payload\") renderEmptyState();\n  else throw err;\n}","handlingStrategy":"try-catch","validationCode":"if (!orgId) throw new Error(\"An active organization is required to fetch a resource snapshot\");","typeGuard":"const isResourceSnapshot = (s: unknown): s is DenResourceSnapshot =>\n  typeof s === \"object\" && s !== null && \"resources\" in s && Array.isArray((s as { resources: unknown }).resources);","tryCatchPattern":"try {\n  snapshot = await client.getResourceSnapshot(orgId);\n} catch (err) {\n  if (err instanceof DenApiError && err.code === \"invalid_resource_snapshot_payload\") {\n    renderSnapshotUnavailable();\n  } else throw err;\n}","preventionTips":["Keep server and client versions aligned to avoid snapshot schema drift","Render an empty/unavailable state instead of crashing when snapshots fail","Log the raw payload on failure to spot schema changes early"],"tags":["schema-validation","den-cloud","api","resources"],"backgroundTag":"schema-validation-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}