{"record":{"id":"71ff35bc56044773","repo":"pypa/pip","slug":"no-such-group","errorCode":null,"errorMessage":"No such group","messagePattern":"No such group","errorType":"exception","errorClass":"IndexError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/pygments/lexer.py","lineNumber":377,"sourceCode":"\nclass _PseudoMatch:\n    \"\"\"\n    A pseudo match object constructed from a string.\n    \"\"\"\n\n    def __init__(self, start, text):\n        self._text = text\n        self._start = start\n\n    def start(self, arg=None):\n        return self._start\n\n    def end(self, arg=None):\n        return self._start + len(self._text)\n\n    def group(self, arg=None):\n        if arg:\n            raise IndexError('No such group')\n        return self._text\n\n    def groups(self):\n        return (self._text,)\n\n    def groupdict(self):\n        return {}\n\n\ndef bygroups(*args):\n    \"\"\"\n    Callback that yields multiple actions for each group in the match.\n    \"\"\"\n    def callback(lexer, match, ctx=None):\n        for i, action in enumerate(args):\n            if action is None:\n                continue\n            elif type(action) is _TokenType:","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/pygments/lexer.py#L359-L395","documentation":"Raised by _PseudoMatch.group(arg) when a non-None, truthy argument is passed. _PseudoMatch is a synthetic match object built from a captured string (used by the bygroups callback when a sub-action needs a match-like object); it only ever holds one 'group', so requesting a named/numbered group raises IndexError('No such group'). This is internal to lexer token-stream processing.","triggerScenarios":"A custom lexer rule uses bygroups(...) with a sub-action that calls match.group(n) for n>0 on a _PseudoMatch, or calls match.group('name'). The pseudo match only supports group(0)/group(None).","commonSituations":"Writing a nested lexer action inside bygroups that tries to access subgroups of a substring match; a regex with no capturing groups used where the action expects them.","solutions":["Restructure the rule so capturing groups are on the outer regex (accessed by the bygroups callback) rather than on the inner pseudo-match.","Avoid calling group(n>0) or group('name') inside a bygroups sub-action callback.","Use a regex with proper capturing groups and let bygroups map them to token types."],"exampleFix":"# before\nbygroups(Name, lambda l, m, ctx: process(m.group(1)))\n# after\nbygroups(Name, lambda l, m, ctx: process(m.group()))  # use the full pseudo-match text","handlingStrategy":"validation","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    ...  # bygroups sub-action calling match.group(n)\nexcept IndexError as e:\n    if 'No such group' in str(e):\n        # fall back to group(0)\n        val = match.group()\n    else:\n        raise","preventionTips":["Do not call group(n>0) or group('name') inside bygroups sub-action callbacks.","Put capturing groups on the outer regex and map them via bygroups."],"tags":["python","pygments","lexer","regex","vendored"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}