langgenius/dify · error · NotFound

Workflow run not found

Error message

Workflow run not found

What it means

Raised as NotFound("Workflow run not found") (HTTP 404) in RagPipelineWorkflowRunDetailApi.get (GET /rag/pipelines/<pipeline_id>/workflow-runs/<run_id>). After asking the service for a workflow run by id, a None result means no run with that run_id exists for this pipeline.

Source

Thrown at api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py:943

    @console_ns.response(
        200,
        "Workflow run detail retrieved successfully",
        console_ns.models[WorkflowRunDetailResponse.__name__],
    )
    @setup_required
    @login_required
    @account_initialization_required
    @get_rag_pipeline
    def get(self, pipeline: Pipeline, run_id: UUID):
        """
        Get workflow run detail
        """
        run_id_str = str(run_id)

        rag_pipeline_service = RagPipelineService(db.session())
        workflow_run = rag_pipeline_service.get_rag_pipeline_workflow_run(pipeline=pipeline, run_id=run_id_str)
        if workflow_run is None:
            raise NotFound("Workflow run not found")

        return WorkflowRunDetailResponse.model_validate(workflow_run, from_attributes=True).model_dump(mode="json")


@console_ns.route("/rag/pipelines/<uuid:pipeline_id>/workflow-runs/<uuid:run_id>/node-executions")
class RagPipelineWorkflowRunNodeExecutionListApi(Resource):
    @console_ns.response(
        200,
        "Node executions retrieved successfully",
        console_ns.models[WorkflowRunNodeExecutionListResponse.__name__],
    )
    @setup_required
    @login_required
    @account_initialization_required
    @get_rag_pipeline
    @with_current_user
    def get(self, current_user: Account, pipeline: Pipeline, run_id: UUID):
        """

View on GitHub (pinned to ef8544b173)

Solutions

  1. Obtain run_id from the workflow-runs list endpoint of the same pipeline, not from an external/cached source.
  2. Poll the runs list rather than a specific run_id until it appears.
  3. Handle 404 by refreshing the runs list.
  4. Confirm the run belongs to pipeline_id in the path.

Example fix

// before
GET /rag/pipelines/<id>/workflow-runs/<guessed-run-id>   // -> 404
// after
runs = await GET /rag/pipelines/<id>/workflow-runs
GET /rag/pipelines/<id>/workflow-runs/<runs[0].id>
Defensive patterns

Strategy: try-catch

Validate before calling

async function getRun(pipelineId, runId) {
  const r = await fetch(`/rag/pipelines/${pipelineId}/workflow-runs/${runId}`);
  if (r.status === 404) return null;
  if (!r.ok) throw await r.json();
  return r.json();
}

Type guard

function isRunReady(runs, runId) { return Array.isArray(runs?.items) && runs.items.some(r => r.id === runId); }

Try / catch

try { const run = await getRun(id, runId); if (!run) refreshRuns(); } catch (e) { /* network */ throw e; }

Prevention

When it happens

Trigger: GET with a run_id that does not exist, belongs to another pipeline, has expired, or has not been created yet. The `if workflow_run is None` branch raises NotFound.

Common situations: Opening a deep link to a run that was deleted/never finished; run_id copied from a different pipeline; polling for a run_id before the run has started; typos in the UUID.

Related errors


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