langgenius/dify · error · ValueError
Missing dataset_id or pipeline_id in request path
Error message
Missing dataset_id or pipeline_id in request path
What it means
A ValueError raised inside _extract_resource_id when a route is declared RBAC-scoped to DATASET but the matched path args contain neither dataset_id (nor legacy resource_id) nor pipeline_id. It is a programming/routing error rather than a client error: the route is wired to RBAC dataset authz but its URL pattern does not supply the identifiers the extractor expects.
Source
Thrown at api/controllers/common/wraps.py:178
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
- Ensure the route URL contains one of dataset_id, resource_id, or pipeline_id as a path converter (e.g. /console/datasets/<uuid:dataset_id>/items).
- If the route legitimately needs a different param name, extend _extract_resource_id's matched_args lookup to recognize it.
- Remove RBACResourceScope.DATASET from the decorator if the route is not dataset-scoped.
- Add a unit test over _extract_resource_id for the new route's path args to prevent regression.
Example fix
# before
@console_ns.route('/datasets/<uuid:library_id>/items')
# after
@console_ns.route('/datasets/<uuid:dataset_id>/items') Defensive patterns
Strategy: validation
Validate before calling
RBAC_DATASET_PATH_PARAMS = {'dataset_id', 'resource_id', 'pipeline_id'}
def route_supports_dataset_rbac(view_args: dict) -> bool:
return bool(set(view_args) & RBAC_DATASET_PATH_PARAMS) Prevention
- When adding a dataset-scoped route, name a path param dataset_id/resource_id/pipeline_id or extend the extractor.
- Add a unit test over _extract_resource_id for every new dataset-scoped route's path args.
- Do not attach RBACResourceScope.DATASET to routes that are not dataset-addressed.
When it happens
Trigger: Adding @rbac_permission_required(RBACResourceScope.DATASET, ...) to a new route whose URL pattern uses a different parameter name (e.g. <library_id> or <collection_id>); deploying a dataset-scoped route without <dataset_id>/<resource_id>/<pipeline_id> in its path. Surfaces as a 500 on first request to that route.
Common situations: New dataset sub-resource endpoint wired with the wrong path parameter name; refactor that renamed a path arg without updating _extract_resource_id's recognized names; copy-paste of an RBAC decorator onto a route that is not actually dataset-addressed.
Related errors
- Dataset not found for pipeline
- export response missing data field
- reconnect stream body missing
- unknown
- usage_missing_arg
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/5ad1768057ebcac2.
Report an issue: GitHub.