{"record":{"id":"c1a1c284f016eb63","repo":"nodejs/node","slug":"unrecognized-enumerated-value-s","errorCode":null,"errorMessage":"unrecognized enumerated value %s","messagePattern":"unrecognized enumerated value (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/MSVSSettings.py","lineNumber":204,"sourceCode":"          In the rare cases where MSVS has skipped an index value, None is\n          used in the array to indicate the unused spot.\n      new: an array of labels that are new to MSBuild.\n    \"\"\"\n\n    def __init__(self, label_list, new=None):\n        _Type.__init__(self)\n        self._label_list = label_list\n        self._msbuild_values = {value for value in label_list if value is not None}\n        if new is not None:\n            self._msbuild_values.update(new)\n\n    def ValidateMSVS(self, value):\n        # Try to convert.  It will raise an exception if not valid.\n        self.ConvertToMSBuild(value)\n\n    def ValidateMSBuild(self, value):\n        if value not in self._msbuild_values:\n            raise ValueError(\"unrecognized enumerated value %s\" % value)\n\n    def ConvertToMSBuild(self, value):\n        index = int(value)\n        if index < 0 or index >= len(self._label_list):\n            raise ValueError(\n                \"index value (%d) not in expected range [0, %d)\"\n                % (index, len(self._label_list))\n            )\n        label = self._label_list[index]\n        if label is None:\n            raise ValueError(\"converted value for %s not specified.\" % value)\n        return label\n\n\n# Instantiate the various generic types.\n_boolean = _Boolean()\n_integer = _Integer()\n# For now, we don't do any special validation on these types:","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/MSVSSettings.py#L186-L222","documentation":"_Enumeration.ValidateMSBuild raises ValueError('unrecognized enumerated value %s') when an enumerated MSBuild setting receives a value not in its allowed _msbuild_values set. The set is built from the enumeration's label list (minus None placeholders) plus any 'new' values added at registration. ValidateMSBuild checks the final MSBuild-side vocabulary, so this fires when the gyp file supplies an MSBuild keyword the enumeration does not know.","triggerScenarios":"Passing a string keyword (e.g. 'MaxSpeed') to a setting whose MSBuild enumeration only lists certain labels; passing a label from a newer/older VS version than the one gyp targets.","commonSituations":"Copy-pasting an MSBuild value from a .vcxproj generated by a different VS version; typo in an enumeration keyword; using a value that is valid for MSVS indices but not for MSBuild labels.","solutions":["Look up the setting in MSVSSettings._msbuild_validators to see the accepted label set and use one of those exact strings.","If migrating between VS versions, translate the old enumeration label to the equivalent in the target version.","Use the integer-index form on the MSVS side (ValidateMSVS/ConvertToMSBuild) which maps indices to labels automatically."],"exampleFix":"# before\n'Optimization': 'Full',   # not in this enumeration's MSBuild labels\n\n# after\n'Optimization': 'MaxSpeed',  # accepted label","handlingStrategy":"validation","validationCode":"def check_enum(setting_name, value, allowed):\n    if value not in allowed:\n        raise ValueError('%s=%r not in allowed %s' % (setting_name, value, sorted(allowed)))\n    return value","typeGuard":"def is_valid_enum_value(value, allowed: set) -> bool:\n    return value in allowed","tryCatchPattern":"try:\n    enum_type.ValidateMSBuild(my_value)\nexcept ValueError:\n    # fall back to a known-safe label or drop the setting\n    my_value = next(iter(enum_type._msbuild_values))\n    enum_type.ValidateMSBuild(my_value)","preventionTips":["Cross-reference each enumeration setting against MSVSSettings.py before assigning.","When migrating VS versions, re-validate every enumeration label.","Prefer MSVS integer indices over label strings to let gyp do the translation."],"tags":["gyp","msbuild","enumeration","validation","settings"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}