{"record":{"id":"33d4e9b66370fdf9","repo":"langgenius/dify","slug":"pipeline-not-found","errorCode":"pipeline_not_found","errorMessage":"Pipeline not found.","messagePattern":"Pipeline not found\\.","errorType":"error_code","errorClass":"PipelineNotFoundError","httpStatus":404,"severity":"error","filePath":"api/controllers/console/datasets/wraps.py","lineNumber":17,"sourceCode":"from collections.abc import Callable\nfrom functools import wraps\n\nfrom sqlalchemy.orm import Session\n\nfrom controllers.console.datasets.error import PipelineNotFoundError\nfrom extensions.ext_database import db\nfrom libs.login import current_account_with_tenant\nfrom models.dataset import Pipeline\nfrom services.rag_pipeline.rag_pipeline import RagPipelineService\n\n\ndef load_rag_pipeline(session: Session, pipeline_id: str) -> Pipeline:\n    _, current_tenant_id = current_account_with_tenant()\n    pipeline = RagPipelineService.get_pipeline_by_id(pipeline_id, current_tenant_id, session=session)\n    if not pipeline:\n        raise PipelineNotFoundError()\n    return pipeline\n\n\ndef get_rag_pipeline[**P, R](view_func: Callable[P, R]) -> Callable[P, R]:\n    @wraps(view_func)\n    def decorated_view(*args: P.args, **kwargs: P.kwargs) -> R:\n        if not kwargs.get(\"pipeline_id\"):\n            raise ValueError(\"missing pipeline_id in path parameters\")\n\n        pipeline_id = kwargs.get(\"pipeline_id\")\n        pipeline_id = str(pipeline_id)\n\n        del kwargs[\"pipeline_id\"]\n        kwargs[\"pipeline\"] = load_rag_pipeline(db.session(), pipeline_id)\n\n        return view_func(*args, **kwargs)\n\n    return decorated_view","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/wraps.py#L1-L35","documentation":"Raised as PipelineNotFoundError (error_code pipeline_not_found, HTTP 404) by load_rag_pipeline in wraps.py, which is invoked by the @get_rag_pipeline decorator used on nearly every /rag/pipelines/<pipeline_id>/... route. When RagPipelineService.get_pipeline_by_id cannot find a pipeline with the given id for the current tenant, the decorator raises this before the view runs.","triggerScenarios":"Any RAG-pipeline route called with a pipeline_id that does not exist, was deleted, or belongs to a different tenant. Also raised if pipeline_id is omitted from kwargs (though that path raises a different ValueError first). Every controller method decorated with @get_rag_pipeline funnels through this check.","commonSituations":"Deep link to a deleted pipeline; pipeline_id copied across tenants/environments; pipeline still being created; permission/tenant scope mismatch on the session.","solutions":["Re-fetch the pipelines list for the current tenant and use a valid pipeline_id.","Confirm the authenticated user belongs to the tenant that owns the pipeline.","On the client, handle pipeline_not_found by refreshing the pipeline list.","Do not persist pipeline_ids across environment switches (dev/staging/prod)."],"exampleFix":"// before\nGET /rag/pipelines/<wrong-id>/workflows            // -> 404 pipeline_not_found\n// after\npipelines = await GET /rag/pipelines\nGET /rag/pipelines/<pipelines[0].id>/workflows","handlingStrategy":"validation","validationCode":"async function withPipeline(pipelineId, fn) {\n  const list = await fetch('/rag/pipelines').then(r => r.json());\n  if (!(list.items ?? []).some(p => p.id === pipelineId)) throw new Error('pipeline_not_found');\n  return fn(pipelineId);\n}","typeGuard":"function isKnownPipelineId(list, id) { return Array.isArray(list?.items) && list.items.some(p => p.id === id); }","tryCatchPattern":"try { return await withPipeline(id, pid => fetchAnyPipelineRoute(pid)); } catch (e) { if (e.code === 'pipeline_not_found' || e.status === 404) refreshPipelines(); else throw e; }","preventionTips":["Fetch the pipeline list for the current tenant before deep-linking.","Handle pipeline_not_found by refreshing.","Do not reuse pipeline_ids across tenants/environments."],"tags":["rag-pipeline","not-found","authorization","http-404"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}