{"record":{"id":"1c96865d9859398e","repo":"different-ai/openwork","slug":"workflow-snapshot-not-found","errorCode":"workflow_snapshot_not_found","errorMessage":"workflow_snapshot_not_found","messagePattern":"workflow_snapshot_not_found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-api/src/workflows.ts","lineNumber":472,"sourceCode":"  })\n  return getWorkflowDetail({ context: input.context, configObjectId: resource.configObject.id })\n}\n\nexport async function deleteWorkflowSnapshotContent(input: {\n  context: PluginArchActorContext\n  configObjectId: string\n  receiptId: string\n}) {\n  const resource = await workflowResource(input.context, input.configObjectId, \"manager\")\n  const receiptId = parseReceiptId(input.receiptId)\n  const rows = await db.select().from(WorkflowRunTable).where(and(\n    eq(WorkflowRunTable.id, receiptId),\n    eq(WorkflowRunTable.organization_id, resource.configObject.organizationId),\n    eq(WorkflowRunTable.config_object_id, resource.configObject.id),\n    isNotNull(WorkflowRunTable.config_object_version_id),\n  )).limit(1)\n  const receipt = rows[0]\n  if (!receipt) throw new Error(\"workflow_snapshot_not_found\")\n  if (!receipt.artifact_content_deleted_at) {\n    await db.update(WorkflowRunTable).set({\n      script_input: null,\n      validated_result: null,\n      result_markdown: null,\n      artifact_content_deleted_at: new Date(),\n    }).where(eq(WorkflowRunTable.id, receipt.id))\n  }\n\n  if (receipt.automation_run_id) {\n    const automationRuns = await db.select({ automationId: AutomationRunTable.automation_id })\n      .from(AutomationRunTable)\n      .where(eq(AutomationRunTable.id, receipt.automation_run_id)).limit(1)\n    const automationId = automationRuns[0]?.automationId\n    if (automationId) {\n      const retained = await db.select({ receipt: WorkflowRunTable, run: AutomationRunTable })\n        .from(WorkflowRunTable)\n        .innerJoin(AutomationRunTable, eq(AutomationRunTable.id, WorkflowRunTable.automation_run_id))","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/workflows.ts#L454-L490","documentation":"Thrown in deleteWorkflowSnapshotContent when no WorkflowRun row matches the given receiptId scoped to the config object's organization and id with a non-null config_object_version_id. The caller asked to delete (redact) a snapshot's content, but no corresponding workflow snapshot exists.","triggerScenarios":"Calling the snapshot deletion route with a receiptId that does not exist, belongs to another org/config object, or whose row has a NULL config_object_version_id (i.e. not a version-producing test run); also firing the request twice after the first deletion partially succeeded — actually deletion is idempotent once found, so repeats mainly fail on wrong ids.","commonSituations":"Already-deleted or pruned workflow runs; typos or stale ids in cleanup scripts; passing an id from a different organization after an org switch in the client.","solutions":["Verify the receiptId belongs to the same organization and config object as the route's resource.","Check the row is a test-run snapshot (config_object_version_id IS NOT NULL) before calling deletion.","Treat the error as not-found: skip or log instead of retrying with the same id."],"exampleFix":"// before\nawait deleteWorkflowSnapshot(receiptId) // any id\n// after\nconst [run] = await db.select().from(WorkflowRunTable)\n  .where(and(eq(WorkflowRunTable.id, receiptId), isNotNull(WorkflowRunTable.config_object_version_id)))\nif (run) await deleteWorkflowSnapshot(receiptId)","handlingStrategy":"try-catch","validationCode":"const [run] = await db.select({ id: WorkflowRunTable.id }).from(WorkflowRunTable)\n  .where(and(eq(WorkflowRunTable.id, receiptId),\n    eq(WorkflowRunTable.organization_id, orgId),\n    eq(WorkflowRunTable.config_object_id, configObjectId),\n    isNotNull(WorkflowRunTable.config_object_version_id))).limit(1)\nconst exists = !!run","typeGuard":null,"tryCatchPattern":"try {\n  await deleteWorkflowSnapshot(receiptId)\n} catch (e) {\n  if (e.message === \"workflow_snapshot_not_found\") {\n    // already gone or wrong id: log and continue\n  } else throw e\n}","preventionTips":["Confirm receiptId scope (org + config object) before calling.","Only target runs with a non-null config_object_version_id.","Make cleanup scripts tolerant of missing snapshots."],"tags":["workflow","not-found","snapshot","den-api"],"backgroundTag":"resource-not-found","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}