langgenius/dify · error · NotFound

Dataset not found for pipeline

Error message

Dataset not found for pipeline

What it means

Raised as werkzeug NotFound (HTTP 404) during RBAC resource-id extraction for a DATASET-scoped route addressed by pipeline_id: the request carried a pipeline_id, but no Dataset row matches Dataset.pipeline_id. Dify resolves pipeline-addressed dataset routes to a concrete dataset_id for authorization, and there is no dataset to authorize against.

Source

Thrown at api/controllers/common/wraps.py:176

        if agent_id:
            authz_app_id = AgentRosterService(db.session).peek_authz_app_id(tenant_id=tenant_id, agent_id=str(agent_id))
            return authz_app_id or str(agent_id)

        resource_id = matched_args.get("resource_id")
        if resource_id:
            return str(resource_id)  # pyrefly: ignore[unnecessary-type-conversion]
        raise ValueError("Missing app_id in request path")

    if resource_type == RBACResourceScope.DATASET:
        dataset_id = matched_args.get("dataset_id") or matched_args.get("resource_id")
        if dataset_id:
            return str(dataset_id)

        pipeline_id = matched_args.get("pipeline_id")
        if pipeline_id:
            dataset = db.session.scalar(select(Dataset).where(Dataset.pipeline_id == str(pipeline_id)))
            if not dataset:
                raise NotFound("Dataset not found for pipeline")
            return str(dataset.id)  # pyrefly: ignore[unnecessary-type-conversion]
        raise ValueError("Missing dataset_id or pipeline_id in request path")
    raise ValueError(f"Unknown resource_type: {resource_type}")

View on GitHub (pinned to ef8544b173)

Solutions

  1. Confirm the pipeline still has a Dataset row: SELECT id FROM datasets WHERE pipeline_id = '<pipeline_id>'; recreate the pipeline/dataset link if missing.
  2. Use the dataset_id-addressed form of the endpoint (dataset_id in the path) instead of pipeline_id if you have the dataset id directly.
  3. Verify the pipeline_id in the request matches the current environment (not a copied cross-env id).
  4. If the pipeline was deleted intentionally, stop polling the endpoint and update the client's stored reference.
Defensive patterns

Strategy: validation

Validate before calling

from sqlalchemy import select
from models.dataset import Dataset

def pipeline_has_dataset(session, pipeline_id: str) -> bool:
    return session.scalar(
        select(Dataset.id).where(Dataset.pipeline_id == str(pipeline_id)).limit(1)
    ) is not None

Try / catch

from werkzeug.exceptions import NotFound

try:
    call_dataset_endpoint(pipeline_id=pipeline_id)
except NotFound as exc:
    if 'Dataset not found for pipeline' in str(exc):
        # pipeline has no dataset: recreate link or use dataset_id form
        pass
    raise

Prevention

When it happens

Trigger: Calling any dataset/rag-pipeline-scoped endpoint keyed by pipeline_id (route pattern with <pipeline_id>) when the pipeline has no associated Dataset row. Common with `/console/datasets/pipelines/<pipeline_id>/...` style routes after the pipeline was deleted or its dataset linkage was never created.

Common situations: Race between pipeline creation and dataset provisioning; a pipeline whose Dataset row was hard-deleted; referencing a pipeline_id copied from another environment; tenant/region mismatch where the pipeline exists but its dataset lives elsewhere.

Related errors


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