{"record":{"id":"e61633da6f2e3ec6","repo":"different-ai/openwork","slug":"connector-sync-event-not-found","errorCode":"connector_sync_event_not_found","errorMessage":"Connector sync event not found.","messagePattern":"Connector sync event not found\\.","errorType":"http","errorClass":"PluginArchRouteFailure","httpStatus":404,"severity":"error","filePath":"ee/apps/den-api/src/routes/org/plugin-system/store.ts","lineNumber":4269,"sourceCode":"    .orderBy(desc(ConnectorSyncEventTable.startedAt), desc(ConnectorSyncEventTable.id))\n\n  const filtered: ReturnType<typeof serializeConnectorSyncEvent>[] = []\n  for (const row of rows) {\n    const role = await resolvePluginArchResourceRole({ context: input.context, resourceId: row.instance.id, resourceKind: \"connector_instance\" })\n    if (!role) continue\n    if (input.connectorInstanceId && row.event.connectorInstanceId !== input.connectorInstanceId) continue\n    if (input.connectorTargetId && row.event.connectorTargetId !== input.connectorTargetId) continue\n    if (input.eventType && row.event.eventType !== input.eventType) continue\n    if (input.status && row.event.status !== input.status) continue\n    if (input.q && !`${row.event.externalEventRef ?? \"\"}\\n${row.event.sourceRevisionRef ?? \"\"}`.toLowerCase().includes(input.q.toLowerCase())) continue\n    filtered.push(serializeConnectorSyncEvent(row.event))\n  }\n  return pageItems(filtered, input.cursor, input.limit)\n}\n\nexport async function getConnectorSyncEventDetail(context: PluginArchActorContext, connectorSyncEventId: ConnectorSyncEventId) {\n  const row = await getConnectorSyncEventRow(context.organizationContext.organization.id, connectorSyncEventId)\n  if (!row) throw new PluginArchRouteFailure(404, \"connector_sync_event_not_found\", \"Connector sync event not found.\")\n  await ensureVisibleConnectorInstance(context, row.connectorInstanceId)\n  return serializeConnectorSyncEvent(row)\n}\n\nexport async function retryConnectorSyncEvent(input: { connectorSyncEventId: ConnectorSyncEventId; context: PluginArchActorContext }) {\n  const row = await getConnectorSyncEventRow(input.context.organizationContext.organization.id, input.connectorSyncEventId)\n  if (!row) throw new PluginArchRouteFailure(404, \"connector_sync_event_not_found\", \"Connector sync event not found.\")\n  await ensureEditableConnectorInstance(input.context, row.connectorInstanceId)\n  await db.update(ConnectorSyncEventTable).set({\n    attemptCount: 0,\n    completedAt: null,\n    nextAttemptAt: null,\n    startedAt: new Date(),\n    status: \"queued\",\n  }).where(eq(ConnectorSyncEventTable.id, row.id))\n  return { id: row.id }\n}\n","sourceCodeStart":4251,"sourceCodeEnd":4287,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/routes/org/plugin-system/store.ts#L4251-L4287","documentation":"Thrown by getConnectorSyncEventDetail when getConnectorSyncEventRow finds no sync event with the given connectorSyncEventId in the caller's organization. The visibility check on the parent connector instance and serialization never run. Org-scoped, so events from other orgs are indistinguishable from nonexistent ones.","triggerScenarios":"Requesting a sync event detail with an ID that was never created, was pruned/retention-deleted, is mistyped, or belongs to another organization.","commonSituations":"Deep links to old sync events after log retention cleanup; polling a sync event ID from a failed/rolled-back sync run; sharing links between two orgs' admin consoles.","solutions":["Re-list sync events for the connector instance to find the current event ID","Confirm the org context of the caller matches the event's organizationId","Check whether retention/job cleanup removed the event row","Fix polling code to handle 404 as terminal state instead of retrying forever"],"exampleFix":"// before\nconst detail = await getConnectorSyncEventDetail(context, eventId) // throws when pruned\n// after\nconst detail = await getConnectorSyncEventDetail(context, eventId).catch((e) =>\n  isPluginArchRouteFailure(e) && e.code === \"connector_sync_event_not_found\" ? null : Promise.reject(e))\nif (!detail) show(\"sync record no longer available\")","handlingStrategy":"try-catch","validationCode":"const events = await listConnectorSyncEvents({ context, connectorInstanceId })\nif (!events.some((ev) => ev.id === eventId)) throw new Error(\"sync event unavailable\")","typeGuard":"function isSyncEventNotFound(e: unknown): boolean {\n  return e instanceof PluginArchRouteFailure && e.code === \"connector_sync_event_not_found\"\n}","tryCatchPattern":"const detail = await getConnectorSyncEventDetail(context, eventId).catch((e) =>\n  isSyncEventNotFound(e) ? null : Promise.reject(e))\nif (!detail) render(\"This sync record is no longer available.\")","preventionTips":["Poll event lists for fresh IDs instead of reusing old deep-link IDs","Expect retention pruning: handle 404 as a terminal UI state","Stop polling when the event 404s rather than looping","Scope stored event IDs by org so cross-org links never form"],"tags":["http-404","not-found","sync-events","connectors"],"backgroundTag":"resource-not-found","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}