{"record":{"id":"ae895c8766a50ded","repo":"langgenius/dify","slug":"dataset-not-found-for-pipeline","errorCode":null,"errorMessage":"Dataset not found for pipeline","messagePattern":"Dataset not found for pipeline","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/common/wraps.py","lineNumber":176,"sourceCode":"        if agent_id:\n            authz_app_id = AgentRosterService(db.session).peek_authz_app_id(tenant_id=tenant_id, agent_id=str(agent_id))\n            return authz_app_id or str(agent_id)\n\n        resource_id = matched_args.get(\"resource_id\")\n        if resource_id:\n            return str(resource_id)  # pyrefly: ignore[unnecessary-type-conversion]\n        raise ValueError(\"Missing app_id in request path\")\n\n    if resource_type == RBACResourceScope.DATASET:\n        dataset_id = matched_args.get(\"dataset_id\") or matched_args.get(\"resource_id\")\n        if dataset_id:\n            return str(dataset_id)\n\n        pipeline_id = matched_args.get(\"pipeline_id\")\n        if pipeline_id:\n            dataset = db.session.scalar(select(Dataset).where(Dataset.pipeline_id == str(pipeline_id)))\n            if not dataset:\n                raise NotFound(\"Dataset not found for pipeline\")\n            return str(dataset.id)  # pyrefly: ignore[unnecessary-type-conversion]\n        raise ValueError(\"Missing dataset_id or pipeline_id in request path\")\n    raise ValueError(f\"Unknown resource_type: {resource_type}\")\n","sourceCodeStart":158,"sourceCodeEnd":180,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/common/wraps.py#L158-L180","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the pipeline still has a Dataset row: SELECT id FROM datasets WHERE pipeline_id = '<pipeline_id>'; recreate the pipeline/dataset link if missing.","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.","Verify the pipeline_id in the request matches the current environment (not a copied cross-env id).","If the pipeline was deleted intentionally, stop polling the endpoint and update the client's stored reference."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from sqlalchemy import select\nfrom models.dataset import Dataset\n\ndef pipeline_has_dataset(session, pipeline_id: str) -> bool:\n    return session.scalar(\n        select(Dataset.id).where(Dataset.pipeline_id == str(pipeline_id)).limit(1)\n    ) is not None","typeGuard":null,"tryCatchPattern":"from werkzeug.exceptions import NotFound\n\ntry:\n    call_dataset_endpoint(pipeline_id=pipeline_id)\nexcept NotFound as exc:\n    if 'Dataset not found for pipeline' in str(exc):\n        # pipeline has no dataset: recreate link or use dataset_id form\n        pass\n    raise","preventionTips":["Prefer dataset_id-addressed routes when you already hold the dataset id.","Provision the Dataset row atomically with pipeline creation.","Stop polling a pipeline endpoint after the pipeline is deleted."],"tags":["rbac","dataset","rag-pipeline","not-found","authz"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}