{"record":{"id":"12d5be7253038a78","repo":"HumanSignal/label-studio","slug":"source-annotation-source-annotation-id-not-found","errorCode":null,"errorMessage":"Source annotation {source_annotation_id} not found in the current project","messagePattern":"Source annotation (.+?) not found in the current project","errorType":"validation","errorClass":"DataManagerException","httpStatus":400,"severity":"error","filePath":"label_studio/data_manager/actions/experimental.py","lineNumber":25,"sourceCode":"from data_manager.actions import DataManagerAction\nfrom data_manager.functions import DataManagerException\nfrom django.conf import settings\nfrom rest_framework.exceptions import ValidationError\nfrom tasks.functions import bulk_create_annotations_with_side_effects\nfrom tasks.models import Annotation, Task\nfrom tasks.serializers import TaskSerializerBulk\n\nlogger = logging.getLogger(__name__)\nall_permissions = AllPermissions()\n\n\ndef propagate_annotations(project, queryset, **kwargs):\n    request = kwargs['request']\n    user = request.user\n    source_annotation_id = request.data.get('source_annotation_id')\n    annotations = Annotation.objects.filter(project=project, id=source_annotation_id)\n    if not annotations:\n        raise DataManagerException(f'Source annotation {source_annotation_id} not found in the current project')\n    source_annotation = annotations.first()\n\n    tasks = set(queryset.values_list('id', flat=True))\n    try:\n        tasks.remove(source_annotation.task.id)\n    except KeyError:\n        pass\n\n    # copy source annotation to new annotations for each task\n    db_annotations = []\n    for i in tasks:\n        body = {\n            'task_id': i,\n            'completed_by_id': user.id,\n            'result': source_annotation.result,\n            'result_count': source_annotation.result_count,\n            'parent_annotation_id': source_annotation.id,\n            'project': project,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_manager/actions/experimental.py#L7-L43","documentation":"propagate_annotations copies a source annotation's results to other tasks in the project. It looks up Annotation.objects.filter(project=project, id=source_annotation_id) from request.data and raises DataManagerException if no annotation matches, i.e. the id is absent, malformed, or belongs to another project.","triggerScenarios":"Calling the propagate_annotations DataManager action without 'source_annotation_id' in request.data, with a nonexistent id, or with an id from a different project; stale id after the annotation was deleted.","commonSituations":"Client caches an annotation id that was later deleted; cross-project UI copy-paste; missing payload field; id passed as string vs int confusion is not an issue here but wrong-project ids are.","solutions":["Fetch a valid annotation id from the project first (GET annotations for the source task) and pass it as source_annotation_id","Confirm the annotation belongs to the same project as the action's project parameter","Handle the DataManagerException client-side and re-select a source annotation"],"exampleFix":"// before\nPOST {\"action\": \"propagate_annotations\", \"source_annotation_id\": 99999}  // not in project\n// after\nconst id = sourceTask.annotations[0].id;\nPOST {\"action\": \"propagate_annotations\", \"source_annotation_id\": id}","handlingStrategy":"validation","validationCode":"const ann = await api.getAnnotation(projectId, sourceAnnotationId);\nif (!ann || ann.project !== projectId) {\n  throw new Error(`Annotation ${sourceAnnotationId} not in project ${projectId}`);\n}","typeGuard":"function isAnnotationInProject(ann, projectId) { return ann != null && ann.project === projectId; }","tryCatchPattern":"try {\n  await dm.addAction({id: 'propagate_annotations', source_annotation_id: id});\n} catch (e) {\n  if (String(e).includes('not found in the current project')) {\n    await reselectSourceAnnotation();\n  } else throw e;\n}","preventionTips":["Always obtain source_annotation_id from a fresh query of the project's annotations","Never reuse ids across projects; validate project ownership before posting","Handle deleted annotations (stale ids) gracefully in the UI"],"tags":["label-studio","data-manager","not-found","api"],"backgroundTag":"resource-not-found","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}