{"record":{"id":"5a042f4fa59cf675","repo":"nodejs/node","slug":"cannot-combine-specifiersets-with-true-and-false-p","errorCode":null,"errorMessage":"Cannot combine SpecifierSets with True and False prerelease overrides.","messagePattern":"Cannot combine SpecifierSets with True and False prerelease overrides\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/packaging/specifiers.py","lineNumber":828,"sourceCode":"        >>> SpecifierSet(\">=1.0.0,!=1.0.1\") & SpecifierSet('<=2.0.0,!=2.0.1')\n        <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>\n        \"\"\"\n        if isinstance(other, str):\n            other = SpecifierSet(other)\n        elif not isinstance(other, SpecifierSet):\n            return NotImplemented\n\n        specifier = SpecifierSet()\n        specifier._specs = frozenset(self._specs | other._specs)\n\n        if self._prereleases is None and other._prereleases is not None:\n            specifier._prereleases = other._prereleases\n        elif self._prereleases is not None and other._prereleases is None:\n            specifier._prereleases = self._prereleases\n        elif self._prereleases == other._prereleases:\n            specifier._prereleases = self._prereleases\n        else:\n            raise ValueError(\n                \"Cannot combine SpecifierSets with True and False prerelease \"\n                \"overrides.\"\n            )\n\n        return specifier\n\n    def __eq__(self, other: object) -> bool:\n        \"\"\"Whether or not the two SpecifierSet-like objects are equal.\n\n        :param other: The other object to check against.\n\n        The value of :attr:`prereleases` is ignored.\n\n        >>> SpecifierSet(\">=1.0.0,!=1.0.1\") == SpecifierSet(\">=1.0.0,!=1.0.1\")\n        True\n        >>> (SpecifierSet(\">=1.0.0,!=1.0.1\", prereleases=False) ==\n        ...  SpecifierSet(\">=1.0.0,!=1.0.1\", prereleases=True))\n        True","sourceCodeStart":810,"sourceCodeEnd":846,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/packaging/specifiers.py#L810-L846","documentation":"ValueError raised by SpecifierSet.__and__ (the & operator) when combining two SpecifierSets whose explicit prerelease overrides conflict - one has _prereleases True and the other False. The combine logic only resolves None-vs-value and equal-value cases; a True-vs-False contradiction cannot be merged deterministically, so it refuses.","triggerScenarios":"Computing SpecifierSet('>=1.0', prereleases=True) & SpecifierSet('>=1.0', prereleases=False) - i.e. intersecting two sets after one had .prereleases (or the prereleases= kwarg) set to True and the other to False.","commonSituations":"Merging requirement specifiers coming from different sources (e.g. user override vs. default config) where one side explicitly enables prereleases and the other explicitly disables them.","solutions":["Normalize both operands to the same prereleases value (or leave them as None for autodetection) before combining.","Compute the intersection of one operand and then set .prereleases afterwards on the result.","Catch ValueError and report which two SpecifierSets conflict so the user can reconcile them."],"exampleFix":"# before\na = SpecifierSet('>=1.0', prereleases=True)\nb = SpecifierSet('>=2.0', prereleases=False)\ncombined = a & b\n\n# after\na = SpecifierSet('>=1.0')\nb = SpecifierSet('>=2.0')\ncombined = a & b\ncombined.prereleases = True","handlingStrategy":"validation","validationCode":"def can_combine(a: SpecifierSet, b: SpecifierSet) -> bool:\n    if a._prereleases is None or b._prereleases is None:\n        return True\n    return a._prereleases == b._prereleases","typeGuard":null,"tryCatchPattern":"try:\n    combined = a & b\nexcept ValueError as e:\n    if 'prerelease' in str(e):\n        b.prereleases = a.prereleases\n        combined = a & b","preventionTips":["Avoid setting .prereleases explicitly on operands you intend to merge.","Centralize prerelease policy in one config location.","Document which SpecifierSets carry an explicit override."],"tags":["packaging","specifiers","prereleases","logic-error"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}