different-ai/openwork · warning · DenApiError

invalid_resource_snapshot_payload

invalid_resource_snapshot_payload

Error message

Resource snapshot response was invalid.

What it means

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.

Source

Thrown at apps/app/src/app/lib/den.ts:2996

    async getDesktopConfig(orgId?: string | null): Promise<DenDesktopConfig> {
      const payload = await requestJson<unknown>(baseUrls, "/v1/me/desktop-config", {
        method: "GET",
        token,
        organizationId: orgId,
      });
      return normalizeDenDesktopConfig(payload);
    },

    async getResourceSnapshot(orgId?: string | null): Promise<DenResourceSnapshot> {
      const payload = await requestJson<unknown>(baseUrls, "/v1/resources", {
        method: "GET",
        token,
        organizationId: orgId,
      });
      const snapshot = normalizeDenResourceSnapshot(payload);
      if (!snapshot) {
        throw new DenApiError(500, "invalid_resource_snapshot_payload", "Resource snapshot response was invalid.");
      }
      return snapshot;
    },

    async exchangeDesktopHandoff(grant: string): Promise<DenDesktopHandoffExchange> {
      const payload = await requestJson<unknown>(baseUrls, "/v1/auth/desktop-handoff/exchange", {
        method: "POST",
        body: { grant },
      });
      return {
        user: getUser(payload),
        token: getToken(payload),
        organization: getExchangeOrganization(payload),
        connectEnabled: getExchangeConnectEnabled(payload),
      };
    },

    async listOrgs(): Promise<{ orgs: DenOrgSummary[]; activeOrgId: string | null; activeOrgSlug: string | null; defaultOrgId: string | null }> {

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Log the raw snapshot payload and compare against the expected DenResourceSnapshot shape
  2. Align server and client versions
  3. Check for proxy interference and correct baseUrl configuration
  4. Handle the error gracefully in UI (show snapshot unavailable)

Example fix

// before
const snapshot = await client.getResourceSnapshot(orgId);
render(snapshot);
// after
try { render(await client.getResourceSnapshot(orgId)); }
catch (err) {
  if (err instanceof DenApiError && err.code === "invalid_resource_snapshot_payload") renderEmptyState();
  else throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!orgId) throw new Error("An active organization is required to fetch a resource snapshot");

Type guard

const isResourceSnapshot = (s: unknown): s is DenResourceSnapshot =>
  typeof s === "object" && s !== null && "resources" in s && Array.isArray((s as { resources: unknown }).resources);

Try / catch

try {
  snapshot = await client.getResourceSnapshot(orgId);
} catch (err) {
  if (err instanceof DenApiError && err.code === "invalid_resource_snapshot_payload") {
    renderSnapshotUnavailable();
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: Server/client version mismatch after an API change, self-hosted deployments with older schemas, or proxies returning unexpected bodies.

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 different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/b589fa1324f03f56. Report an issue: GitHub.