HumanSignal/label-studio · error · DataManagerException
Project and View mismatch
Error message
Project and View mismatch
What it means
get_prepare_params in label_studio/data_manager/functions.py loads an optional saved View by id and applies its filters/selected items. When the View's project id differs from the project the request targets, it raises DataManagerException('Project and View mismatch') because a view must never be applied to another project's task queryset.
Source
Thrown at label_studio/data_manager/functions.py:289
},
]
result['columns'].append(data_root)
return result
def get_prepare_params(request, project):
"""This function extract prepare_params from
* view_id if it's inside of request data
* selectedItems, filters, ordering if they are in request and there is no view id
"""
# use filters and selected items from view
view_id = int_from_request(request.GET, 'view', 0) or int_from_request(request.data, 'view', 0)
if view_id > 0:
view = get_object_or_404(View, pk=view_id)
if view.project.pk != project.pk:
raise DataManagerException('Project and View mismatch')
prepare_params = view.get_prepare_tasks_params(add_selected_items=True)
prepare_params.request = request
# use filters and selected items from request if it's specified
else:
# query arguments from url
if 'query' in request.GET:
data = json.loads(unquote(request.GET['query']))
# data payload from body
else:
data = request.data
selected = data.get('selectedItems', {'all': True, 'excluded': []})
if not isinstance(selected, dict):
if isinstance(selected, str):
# try to parse JSON string
try:
selected = json.loads(selected)View on GitHub (pinned to 0b49e9b539)
Solutions
- Use a view id that belongs to the same project as the request's project parameter
- Re-fetch the correct view id for the target project via the views API (GET /api/storages or /api/datasets/views?project=<id>)
- Remove the view parameter so filters come from the request itself
- If the view was moved/cloned, recreate it in the target project and update stored references
Example fix
// before GET /api/tasks?project=12&view=77 # view 77 belongs to project 9 // after GET /api/tasks?project=12&view=104 # view created under project 12
Defensive patterns
Strategy: validation
Validate before calling
const res = await fetch(`/api/views/${viewId}`); const view = await res.json();
if (String(view.project) !== String(projectId)) throw new Error(`View ${viewId} belongs to project ${view.project}, not ${projectId}`); Type guard
const viewMatchesProject = (view, projectId) => view != null && String(view.project) === String(projectId);
Try / catch
try { const params = await getPrepareParams(...); } catch (e) { if (e instanceof DataManagerException && /Project and View mismatch/.test(e.message)) { reloadViewForProject(projectId); } else { throw e; } } Prevention
- Store view ids together with their project id and verify on use
- Re-fetch views per project instead of caching a single global view id
- Never copy Data Manager URLs between projects without clearing the ?view= param
- In scripts, resolve the view by name within the target project each run
When it happens
Trigger: A Data Manager API call (GET list, POST actions, or get_prepared_queryset) passes ?view=<id> (or view in request.data) whose View row belongs to project A while the URL/project parameter is project B.
Common situations: Hardcoded or stale view ids in scripts/automations; copying an integrations URL from one project to another; a view shared or serialized into another project after project deletion/recreation; frontend state referencing a view from a previously opened project.
Related errors
- sample() does not accept arguments.
- random(min, max) requires two arguments.
- choices(values:list, weights:list) requires one or two argum
- replace(old_value, new_value) requires two arguments.
- Undefined expression, you can use: {add_data_field_examples}
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/2be0cd14f1d73a78.
Report an issue: GitHub.