{"record":{"id":"ae4291fdc55ac083","repo":"langgenius/dify","slug":"failed-to-apply-graph-new-app-orphanappid-may","errorCode":null,"errorMessage":"Failed to apply graph; new app ${orphanAppId} may be orphaned.","messagePattern":"Failed to apply graph; new app (.+?) may be orphaned\\.","errorType":"exception","errorClass":"WorkflowApplyOrphanError","httpStatus":null,"severity":"error","filePath":"web/app/components/workflow/workflow-generator/apply.ts","lineNumber":131,"sourceCode":"  // user isn't left with a discoverable-but-empty app sitting at the top\n  // of their /apps list. ``deleteApp`` is best-effort — if that also fails\n  // (it usually won't, it's a simple DELETE) we surface ``WorkflowApplyOrphanError``\n  // so the caller can route to /apps where the orphan is still recoverable\n  // by hand.\n  try {\n    await syncWorkflowDraft({\n      url: `apps/${app.id}/workflows/draft`,\n      params: {\n        graph,\n        features: {},\n        conversation_variables: [],\n      },\n    })\n  } catch (syncErr) {\n    try {\n      await deleteApp(app.id)\n    } catch (deleteErr) {\n      throw new WorkflowApplyOrphanError(app.id, deleteErr)\n    }\n    throw syncErr\n  }\n\n  return { appId: app.id, appMode, permissionKeys: app.permission_keys }\n}\n\ntype ApplyToCurrentAppParams = {\n  appId: string\n  graph: GeneratedGraph\n}\n\n/**\n * Apply path B — overwrite the current Workflow Studio's draft graph.\n *\n * The backend's ``sync_draft_workflow`` rejects writes whose ``hash`` doesn't\n * match the existing draft's ``unique_hash`` (WorkflowHashNotEqualError), so we\n * must read the current draft first to grab its hash. We also preserve the","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/web/app/components/workflow/workflow-generator/apply.ts#L113-L149","documentation":"Error \"Failed to apply graph; new app ${orphanAppId} may be orphaned.\" thrown in langgenius/dify.","triggerScenarios":"Thrown at web/app/components/workflow/workflow-generator/apply.ts:131 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}