langgenius/dify · error · NotFoundError
Draft workflow not found, pipeline_id={pipeline.id}
Error message
Draft workflow not found, pipeline_id={pipeline.id} What it means
Returned (HTTP 404, `not_found`) by PUT /rag/pipelines/<pipeline_id>/workflows/draft/variables/<variable_id>/reset when `RagPipelineService.get_draft_workflow(pipeline)` returns None. Reset requires a draft workflow graph to recompute the variable's default value, so a missing draft workflow is a hard precondition. Note this uses generic NotFoundError rather than the typed DraftWorkflowNotExist used elsewhere.
Source
Thrown at api/controllers/console/datasets/rag_pipeline/rag_pipeline_draft_variable.py:303
draft_var_srv.delete_variable(variable)
db.session.commit()
return Response("", 204)
@console_ns.route("/rag/pipelines/<uuid:pipeline_id>/workflows/draft/variables/<uuid:variable_id>/reset")
class RagPipelineVariableResetApi(Resource):
@console_ns.response(200, "Variable reset successfully", workflow_draft_variable_model)
@console_ns.response(204, "Variable reset (no content)")
@_api_prerequisite
def put(self, _current_user: Account, pipeline: Pipeline, variable_id: UUID):
draft_var_srv = WorkflowDraftVariableService(
session=db.session(),
)
rag_pipeline_service = RagPipelineService(db.session())
draft_workflow = rag_pipeline_service.get_draft_workflow(pipeline=pipeline)
if draft_workflow is None:
raise NotFoundError(
f"Draft workflow not found, pipeline_id={pipeline.id}",
)
variable_id_str = str(variable_id)
variable = draft_var_srv.get_variable(variable_id=variable_id_str)
if variable is None:
raise NotFoundError(description=f"variable not found, id={variable_id_str}")
if variable.app_id != pipeline.id:
raise NotFoundError(description=f"variable not found, id={variable_id_str}")
resetted = draft_var_srv.reset_variable(draft_workflow, variable)
db.session.commit()
if resetted is None:
return Response("", 204)
else:
return marshal(resetted, _WORKFLOW_DRAFT_VARIABLE_FIELDS)
def _get_variable_list(pipeline: Pipeline, node_id: str, current_user_id: str) -> WorkflowDraftVariableList:View on GitHub (pinned to ef8544b173)
Solutions
- Initialize the draft workflow first via POST /rag/pipelines/<pipeline_id>/workflows/draft with the graph payload.
- Confirm with GET /rag/pipelines/<pipeline_id>/workflows/draft that a draft exists before exposing the reset action.
- Disable the reset control in the UI until a draft workflow is present.
- If the draft was intentionally removed, recreate it from the published workflow (restore endpoint) before reset.
Example fix
// before
await put(`/rag/pipelines/${pid}/workflows/draft/variables/${vid}/reset`)
// after
const draft = await getDraft(pid)
if (!draft) {
await initDraft(pid, graphPayload) // POST /workflows/draft
}
await put(`/rag/pipelines/${pid}/workflows/draft/variables/${vid}/reset`) Defensive patterns
Strategy: validation
Validate before calling
const draft = await fetch(`/rag/pipelines/${pid}/workflows/draft`).then(r => r.ok ? r.json() : null)
if (!draft) {
// initialize or restore draft before reset
await post(`/rag/pipelines/${pid}/workflows/draft`, { graph: starterGraph })
}
await put(`${base}/variables/${vid}/reset`) Try / catch
try {
await put(`${base}/variables/${vid}/reset`)
} catch (e) {
if (e.status === 404 && /Draft workflow not found/.test(e.message)) {
// initialize draft, then retry once
} else throw e
} Prevention
- Guarantee a draft workflow exists (GET .../workflows/draft returns 200) before exposing reset.
- Disable the reset control until draft initialization completes.
- If draft is missing, offer to restore from the published workflow.
When it happens
Trigger: Calling reset on a pipeline whose draft workflow was never created, was deleted, or whose initialization is still pending. Also triggered when the pipeline itself was just created and no draft has been synced yet via POST /workflows/draft.
Common situations: New pipeline that hasn't been initialized through the editor. Draft workflow deleted by an admin action. Race between pipeline creation and the first sync_draft_workflow call.
Related errors
- draft_workflow_not_exist
- draft_workflow_not_exist
- draft_workflow_not_sync
- Conversation Not Exists.
- expected dict for file, got {type(raw_value)}
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/479c9f247ab8e80f.
Report an issue: GitHub.