langgenius/dify · warning · DraftWorkflowNotSync

draft_workflow_not_sync

draft_workflow_not_sync

Error message

Workflow graph might have been modified, please refresh and resubmit.

What it means

Raised as DraftWorkflowNotSync when WorkflowService.sync_draft_workflow raises WorkflowHashNotEqualError (api/controllers/console/app/workflow.py:671-672). The client-supplied hash (SyncDraftWorkflowPayload.hash) does not match the server's current draft hash, meaning the draft was modified since the client last loaded it. The server refuses the sync to prevent a blind overwrite of concurrent changes.

Source

Thrown at api/controllers/console/app/workflow.py:672

                variable_factory.build_conversation_variable_from_mapping(obj)
                for obj in args_model.conversation_variables
            ]
            workflow = workflow_service.sync_draft_workflow(
                app_model=app_model,
                graph=args_model.graph,
                features=args_model.features,
                unique_hash=args_model.hash,
                account=current_user,
                environment_variables=[],
                conversation_variables=conversation_variables,
                session=db.session(),
                environment_variable_upserts=environment_variable_upserts,
                deleted_environment_variable_ids=deleted_environment_variable_ids,
                preserve_environment_variables=True,
                graph_only=args_model.is_collaborative,
            )
        except WorkflowHashNotEqualError:
            raise DraftWorkflowNotSync()
        except VariableError as e:
            raise InvalidArgumentError(description=str(e))

        return dump_response(
            SyncDraftWorkflowResponse,
            {
                "result": "success",
                "hash": workflow.unique_hash,
                "updated_at": TimestampField().format(workflow.updated_at or workflow.created_at),
            },
        )


@console_ns.route("/apps/<uuid:app_id>/advanced-chat/workflows/draft/run")
class AdvancedChatDraftWorkflowRunApi(Resource):
    @console_ns.doc("run_advanced_chat_draft_workflow")
    @console_ns.doc(description="Run draft workflow for advanced chat application")
    @console_ns.doc(params={"app_id": "Application ID"})

View on GitHub (pinned to ef8544b173)

Solutions

  1. GET the current draft workflow to obtain the latest hash and graph, reconcile local edits, then re-POST with the fresh hash.
  2. Use collaborative mode (is_collaborative / _is_collaborative) if supported, to coordinate concurrent edits.
  3. Avoid keeping a draft open and unsaved across long idle periods; save promptly.
  4. Surface this error to the user as 'refresh required' and merge or discard local changes explicitly.
Defensive patterns

Strategy: retry

Validate before calling

// Load the latest hash right before sync to reduce staleness
const fresh = await getDraftWorkflow(appId)
payload.hash = fresh.hash
await syncDraft(appId, payload)

Try / catch

try {
  await syncDraft(appId, payload)
} catch (e) {
  if (e.code === 'draft_workflow_not_sync') {
    const fresh = await getDraftWorkflow(appId)
    payload.hash = fresh.hash
    // merge or discard local edits, then retry once
    return syncDraft(appId, payload)
  }
  throw e
}

Prevention

When it happens

Trigger: POSTing a draft-workflow sync with a stale hash — another user/session saved the same draft after the client loaded it, or the same client saved in another tab. The hash mismatch triggers WorkflowHashNotEqualError inside sync_draft_workflow.

Common situations: Collaborative editing with two editors; same user editing in two tabs; long idle between load and save where an autosave/another session changed the graph; client using an outdated cached hash after a reconnect.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/80d361d5c83268e0. Report an issue: GitHub.