{"record":{"id":"9e953c9e866223d7","repo":"different-ai/openwork","slug":"app-revision-not-found","errorCode":"app_revision_not_found","errorMessage":"The active app revision was not found.","messagePattern":"The active app revision was not found\\.","errorType":"http","errorClass":"RemoteMcpAppError","httpStatus":404,"severity":"error","filePath":"ee/apps/den-api/src/remote-mcp-apps.ts","lineNumber":513,"sourceCode":"  const app = await getAppRow(input.context, input.configObjectId)\n  const role = await resolvePluginArchResourceRole({ context: input.context, resourceId: app.configObjectId, resourceKind: \"config_object\" })\n  if (!role) throw new RemoteMcpAppError(404, \"remote_app_not_found\", \"Remote MCP App not found.\")\n  return serializeApp(app, role)\n}\n\nexport async function refreshRemoteMcpApp(input: {\n  context: PluginArchActorContext\n  configObjectId: string\n  sourceUrl?: string\n}) {\n  const app = await getAppRow(input.context, input.configObjectId, \"editor\")\n  if (!app.activeVersionId) throw new RemoteMcpAppError(409, \"app_has_no_active_revision\", \"Activate an app revision before caching an update.\")\n  const activeVersions = await db.select().from(ConfigObjectVersionTable).where(and(\n    eq(ConfigObjectVersionTable.configObjectId, app.configObjectId),\n    eq(ConfigObjectVersionTable.id, app.activeVersionId),\n    eq(ConfigObjectVersionTable.isDeletedVersion, false),\n  )).limit(1)\n  if (!activeVersions[0]) throw new RemoteMcpAppError(404, \"app_revision_not_found\", \"The active app revision was not found.\")\n  const fetched = await fetchRemoteMcpApp(input.sourceUrl ?? app.sourceUrl)\n  await createConfigObjectVersion({\n    context: input.context,\n    configObjectId: app.configObjectId,\n    reason: fetched.digest,\n    value: {\n      normalizedPayloadJson: payloadForFetchedApp(fetched) as unknown as Record<string, unknown>,\n      rawSourceText: fetched.html,\n      schemaVersion: REMOTE_MCP_APP_CONFIG_SCHEMA_VERSION,\n    },\n  })\n  const updatedAt = new Date()\n  await db.update(RemoteMcpAppTable).set({\n    sourceUrl: fetched.sourceUrl,\n    resolvedSourceUrl: fetched.resolvedSourceUrl,\n    updatedAt,\n  }).where(eq(RemoteMcpAppTable.configObjectId, app.configObjectId))\n  const updated = { ...app, sourceUrl: fetched.sourceUrl, resolvedSourceUrl: fetched.resolvedSourceUrl, updatedAt }","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/remote-mcp-apps.ts#L495-L531","documentation":"After confirming the app has an activeVersionId, refreshRemoteMcpApp queries ConfigObjectVersionTable for that exact version scoped to the app and not soft-deleted. If the row is gone (hard delete, purge, or isDeletedVersion flip), the baseline revision no longer exists and it throws 404 app_revision_not_found.","triggerScenarios":"Calling refreshRemoteMcpApp when the active version row is missing: the version was soft-deleted (isDeletedVersion=true), hard-deleted by cleanup, or activeVersionId points at a version from a different/rolled-back config object.","commonSituations":"Version GC/purge jobs removing old revisions while an app still references one; database restore pointing activeVersionId at a lost row; data migration leaving dangling references.","solutions":["Activate an existing, non-deleted revision via activateRemoteMcpAppRevision to repair activeVersionId.","Re-import the app (importRemoteMcpApp) if all its revisions were purged.","Check config-object version cleanup jobs for deletes that should be blocked for versions referenced by RemoteMcpAppTable.activeVersionId."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await refreshRemoteMcpApp({ context, configObjectId }) } catch (e) {\n  if (e instanceof RemoteMcpAppError && e.code === 'app_revision_not_found') {\n    // active revision is dangling: activate an existing revision or re-import the app\n  }\n}","preventionTips":["Exclude versions referenced by RemoteMcpAppTable.activeVersionId from purge/GC jobs","After DB restores or migrations, validate activeVersionId references resolve","Re-import apps whose revision history was wiped"],"tags":["not-found","data-integrity","http-404","soft-delete"],"backgroundTag":"dangling-reference","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}