{"record":{"id":"bc1fca1fcacd8b15","repo":"HumanSignal/label-studio","slug":"toname-toname-not-found-in-names-sorted-name","errorCode":null,"errorMessage":"toName=\"{toName}\" not found in names: {sorted(names)}","messagePattern":"toName=\"(.+?)\" not found in names: (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"label_studio/core/label_config.py","lineNumber":135,"sourceCode":"        # we pick the first failed schema and show only its error message\n        error_message = exc.context[0].message if len(exc.context) else exc.message\n        error_message = 'Validation failed on {}: {}'.format(\n            '/'.join(map(str, exc.path)), error_message.replace('@', '')\n        )\n        raise ValidationError(error_message)\n\n    # unique names in config # FIXME: 'name =' (with spaces) won't work\n    all_names = re.findall(r'(?:^|[^\\w])name=\"([^\"]*)\"', cleaned_config_string)\n    if len(set(all_names)) != len(all_names):\n        raise ValidationError('Label config contains non-unique names: ' + ', '.join(all_names))\n\n    # toName points to existent name\n    names = set(all_names)\n    toNames = re.findall(r'toName=\"([^\"]*)\"', cleaned_config_string)\n    for toName_ in toNames:\n        for toName in toName_.split(','):\n            if toName not in names:\n                raise ValidationError(f'toName=\"{toName}\" not found in names: {sorted(names)}')\n\n    # Tag attribute validation (e.g. Video playback speed) via SDK\n    try:\n        li = LabelInterface(config_string)\n        if hasattr(li, '_tag_attribute_validation'):\n            li._tag_attribute_validation()\n    except LabelStudioValidationErrorSentryIgnored as exc:\n        raise ValidationError(str(exc))\n\n\ndef extract_data_types(label_config):\n    # load config\n    xml = parse_config_to_xml(label_config)\n    if xml is None:\n        raise etree.ParseError('Project config is empty or incorrect')\n\n    # take all tags with values attribute and fit them to tag types\n    data_type = {}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/core/label_config.py#L117-L153","documentation":"Every toName=\"...\" reference in the label config must point to a name declared by another tag. validate_label_config splits comma-separated toName lists and raises this ValidationError listing the missing name and the sorted set of known names when a reference is dangling.","triggerScenarios":"Saving a config where a tag's toName attribute references a name that no tag declares — e.g. <Choices toName=\"text\"> with no tag named text; also triggered by a typo in toName, or after renaming/deleting a source tag.","commonSituations":"Deleting or renaming a tag while leaving its consumers' toName unchanged; typos (case-sensitive mismatch); forgetting the controlling tag entirely in minimal configs.","solutions":["Add a tag with the referenced name, or fix toName to match an existing tag name exactly (case-sensitive).","Cross-check each toName value against the sorted names list included in the error message.","After renaming a tag, update every toName that referenced the old name.","If a tag controls multiple targets, list them comma-separated in toName, e.g. toName=\"text,audio\"."],"exampleFix":"<!-- before: toName references nonexistent name 'txet' -->\n<Text name=\"text\" value=\"$doc\"/>\n<Choices name=\"sentiment\" toName=\"txet\">...</Choices>\n<!-- after -->\n<Text name=\"text\" value=\"$doc\"/>\n<Choices name=\"sentiment\" toName=\"text\">...</Choices>","handlingStrategy":"validation","validationCode":"import re\ndef to_names_resolve(config: str) -> bool:\n    names = set(re.findall(r'(?:^|[^\\w])name=\"([^\"]*)\"', config))\n    return all(t in names for to in re.findall(r'toName=\"([^\"]*)\"', config) for t in to.split(','))","typeGuard":null,"tryCatchPattern":"try:\n    validate_label_config(config)\nexcept ValidationError as e:\n    if 'not found in names' in str(e):\n        return Response({'error': str(e), 'hint': 'toName must reference an existing tag name'}, status=400)\n    raise","preventionTips":["After renaming a tag, grep the config for its old name to fix toName references.","Keep each toName value exactly matching a declared name (case-sensitive).","Use the UI editor, which flags unresolved toName references.","Add a lint step that cross-checks toName against declared names."],"tags":["validation","label-config","xml"],"backgroundTag":"dangling-reference","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}