{"record":{"id":"d8cf6a938e9082dd","repo":"different-ai/openwork","slug":"invalid-cached-app","errorCode":"invalid_cached_app","errorMessage":"The cached app revision metadata is invalid.","messagePattern":"The cached app revision metadata is invalid\\.","errorType":"http","errorClass":"RemoteMcpAppError","httpStatus":422,"severity":"error","filePath":"ee/apps/den-api/src/remote-mcp-apps.ts","lineNumber":340,"sourceCode":"    source: {\n      url: fetched.sourceUrl,\n      resolvedUrl: fetched.resolvedSourceUrl,\n      fetchedAt: fetched.fetchedAt,\n      contentType: fetched.contentType,\n    },\n    resource: {\n      byteSize: fetched.byteSize,\n      digest: fetched.digest,\n      csp: { connectDomains: [], resourceDomains: [], frameDomains: [], baseUriDomains: [] },\n    },\n    diagnostics: fetched.diagnostics,\n  }\n}\n\nfunction parseVersionPayload(row: Pick<RemoteMcpAppVersionRow, \"normalizedPayloadJson\">): RemoteMcpAppVersionPayload {\n  const value = row.normalizedPayloadJson\n  if (!isRecord(value) || value.kind !== \"remote_mcp_app\") {\n    throw new RemoteMcpAppError(422, \"invalid_cached_app\", \"The cached app revision metadata is invalid.\")\n  }\n  const metadata = remoteMcpAppDocumentMetadataSchema.safeParse(value.metadata)\n  const source = isRecord(value.source) ? value.source : null\n  const resource = isRecord(value.resource) ? value.resource : null\n  if (!metadata.success || !source || !resource\n    || typeof source.url !== \"string\" || typeof source.resolvedUrl !== \"string\" || typeof source.fetchedAt !== \"string\"\n    || (source.contentType !== null && typeof source.contentType !== \"string\")\n    || typeof resource.byteSize !== \"number\" || typeof resource.digest !== \"string\") {\n    throw new RemoteMcpAppError(422, \"invalid_cached_app\", \"The cached app revision metadata is invalid.\")\n  }\n  return value as RemoteMcpAppVersionPayload\n}\n\nasync function getAppRow(context: PluginArchActorContext, configObjectId: string, role: \"viewer\" | \"editor\" | \"manager\" = \"viewer\") {\n  let id: DenTypeId<\"configObject\">\n  try {\n    id = normalizeDenTypeId(\"configObject\", configObjectId)\n  } catch {","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/remote-mcp-apps.ts#L322-L358","documentation":"parseVersionPayload validates the JSON payload stored in a remote MCP app version row. If normalizedPayloadJson is not a record, or its kind is not \"remote_mcp_app\", this 422 invalid_cached_app error is thrown: the cached revision metadata in the database is unreadable or was written by an incompatible writer.","triggerScenarios":"Reading an app version row (via serializeRevision/payload callers) whose normalizedPayloadJson column is null, malformed, or has kind != \"remote_mcp_app\" — e.g. rows written by an older schema version or corrupted by a failed migration.","commonSituations":"Manual DB edits or partial migrations leaving rows without the payload envelope; a version upgrade changing the payload shape; importing/copying rows between environments with different payload formats.","solutions":["Delete/re-import the affected app so the revision payload is regenerated from the source URL.","Restore the row's normalizedPayloadJson from a backup taken before the corruption.","Run the pending den-api migrations that backfill payload kind/metadata.","Check the den-api version that wrote the row matches the version reading it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isValidAppPayload(v: unknown): boolean {\n  return typeof v === \"object\" && v !== null && (v as Record<string, unknown>).kind === \"remote_mcp_app\";\n}","tryCatchPattern":"try {\n  const revision = await getRemoteMcpAppRevision(context, configObjectId);\n} catch (e) {\n  if (e instanceof RemoteMcpAppError && e.code === \"invalid_cached_app\") {\n    // cache is corrupt; re-import the app from its source URL\n  } else throw e;\n}","preventionTips":["Never hand-edit normalizedPayloadJson rows in the database.","Keep den-api migrations applied so old rows are backfilled to the current payload envelope.","Re-import apps after major version upgrades that change payload shape.","Back up the remote MCP app tables before migrations."],"tags":["database","cache","schema","remote-mcp-app"],"backgroundTag":"invalid-cached-payload","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}