{"record":{"id":"d7aeebdc579d7170","repo":"HumanSignal/label-studio","slug":"wrong-old-label-name-it-is-not-from-labeling-conf","errorCode":null,"errorMessage":"Wrong old label name, it is not from labeling config: {old_label_name}","messagePattern":"Wrong old label name, it is not from labeling config: (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_manager/actions/experimental.py","lineNumber":83,"sourceCode":"    field = {\n        'type': 'number',\n        'name': 'source_annotation_id',\n        'label': 'Enter source annotation ID'\n        + (f' [first ID: {str(first_annotation.id)}]' if first_annotation else ''),\n    }\n    return [{'columnCount': 1, 'fields': [field]}]\n\n\ndef rename_labels(project, queryset, **kwargs):\n    request = kwargs['request']\n\n    old_label_name = request.data.get('old_label_name')\n    new_label_name = request.data.get('new_label_name')\n    control_tag = request.data.get('control_tag')\n\n    labels = project.get_parsed_config()\n    if control_tag not in labels:\n        raise ValidationError('Wrong old label name, it is not from labeling config: ' + old_label_name)\n    label_type = labels[control_tag]['type'].lower()\n\n    annotations = Annotation.objects.filter(project=project)\n    if settings.DJANGO_DB == settings.DJANGO_DB_SQLITE:\n        annotations = annotations.filter(result__icontains=control_tag).filter(result__icontains=old_label_name)\n    else:\n        annotations = annotations.filter(result__contains=[{'from_name': control_tag}]).filter(\n            result__contains=[{'value': {label_type: [old_label_name]}}]\n        )\n\n    label_count = 0\n    annotation_count = 0\n    for annotation in annotations:\n        changed = False\n        for sub in annotation.result:\n            if sub.get('from_name', None) == control_tag and old_label_name in sub.get('value', {}).get(\n                label_type, []\n            ):","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_manager/actions/experimental.py#L65-L101","documentation":"rename_labels renames a label across annotations by control tag. It parses the project's labeling config via project.get_parsed_config() and raises ValidationError if control_tag is not a key in the parsed labels map — meaning the given control tag (and old label) does not exist in the current labeling configuration.","triggerScenarios":"Calling rename_labels with request.data['control_tag'] absent or not present in the parsed config (e.g. 'label' when config uses 'choices'), or a tag from a previous config version.","commonSituations":"Config was edited/renamed so the control tag changed; passing the label name instead of the control tag name; extra whitespace/case mismatch; organizations renaming tags in Label Config XML without migrating annotations.","solutions":["Pass the exact control tag name from the labeling config (e.g. <Choices name=\"sentiment\"> → control_tag \"sentiment\"), not the label value","Verify with the parsed config (project.get_parsed_config()) that the tag exists before calling","Update labeling config references if the tag was renamed"],"exampleFix":"// before\n{\"control_tag\": \"label\", \"old_label_name\": \"Positive\", \"new_label_name\": \"Good\"}  // config has <Choices name=\"sentiment\">\n// after\n{\"control_tag\": \"sentiment\", \"old_label_name\": \"Positive\", \"new_label_name\": \"Good\"}","handlingStrategy":"validation","validationCode":"const parsed = project.get_parsed_config(); // or fetch config-derived labels via API\nif (!(controlTag in parsed)) {\n  throw new Error(`control_tag ${controlTag} missing from labeling config`);\n}","typeGuard":"function controlTagExists(parsedConfig, tag) { return tag != null && Object.prototype.hasOwnProperty.call(parsedConfig, tag); }","tryCatchPattern":"try {\n  await dm.addAction({id: 'rename_labels', control_tag: tag, old_label_name: oldL, new_label_name: newL});\n} catch (e) {\n  if (String(e).includes('Wrong old label name')) {\n    promptRepickControlTag();\n  } else throw e;\n}","preventionTips":["Populate the control-tag selector from the parsed labeling config, not free text","Re-validate config-derived labels after any config edit","Send the tag name attribute, never a label value, as control_tag"],"tags":["label-studio","validation","labeling-config","api"],"backgroundTag":"invalid-config-reference","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}