{"id":"4b4ced204a131d72","repo":"pypa/pip","slug":"invalid-specification-s","errorCode":null,"errorMessage":"Invalid specification '%s'","messagePattern":"Invalid specification '(.+?)'","errorType":"validation","errorClass":"DistlibException","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/distlib/util.py","lineNumber":729,"sourceCode":"                      and self.flags == other.flags)\n        return result\n\n    __hash__ = object.__hash__\n\n\nENTRY_RE = re.compile(\n    r'''(?P<name>([^\\[]\\S*))\n                      \\s*=\\s*(?P<callable>(\\w+)([:\\.]\\w+)*)\n                      \\s*(\\[\\s*(?P<flags>[\\w-]+(=\\w+)?(,\\s*\\w+(=\\w+)?)*)\\s*\\])?\n                      ''', re.VERBOSE)\n\n\ndef get_export_entry(specification):\n    m = ENTRY_RE.search(specification)\n    if not m:\n        result = None\n        if '[' in specification or ']' in specification:\n            raise DistlibException(\"Invalid specification \"\n                                   \"'%s'\" % specification)\n    else:\n        d = m.groupdict()\n        name = d['name']\n        path = d['callable']\n        colons = path.count(':')\n        if colons == 0:\n            prefix, suffix = path, None\n        else:\n            if colons != 1:\n                raise DistlibException(\"Invalid specification \"\n                                       \"'%s'\" % specification)\n            prefix, suffix = path.split(':')\n        flags = d['flags']\n        if flags is None:\n            if '[' in specification or ']' in specification:\n                raise DistlibException(\"Invalid specification \"\n                                       \"'%s'\" % specification)","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/distlib/util.py#L711-L747","documentation":"Raised by get_export_entry() when parsing an entry-point specification. ENTRY_RE did not match the string, but the string contains '[' or ']', which indicates a malformed flags/bracket section. A DistlibException 'Invalid specification' is raised to tell the caller the entry-point string is not in the expected 'name = module[:attr] [flags]' form.","triggerScenarios":"get_export_entry('foo = bar.baz [bad flag]') (brackets present but regex fails), get_export_entry('foo[] = bar'), or any entry_points spec where brackets appear but the overall grammar does not match ENTRY_RE.","commonSituations":"Hand-editing entry_points in setup.cfg/pyproject.toml and mismatching brackets, trailing spaces inside brackets, or flags with illegal characters.","solutions":["Rewrite the spec in the canonical form 'name = pkg.module:attr [flag1, flag2]' with balanced brackets.","Remove the brackets entirely if no flags are needed.","Ensure there are no stray '[' or ']' elsewhere in the string."],"exampleFix":"// before\nget_export_entry('cli = mypkg.cli:main [console)')\n// after\nget_export_entry('cli = mypkg.cli:main [console]')","handlingStrategy":"validation","validationCode":"import re\nENTRY_RE = re.compile(r'(?P<name>([^\\[]\\S*))\\s*=\\s*(?P<callable>(\\w+)([:\\.]\\w+)*)\\s*(\\[\\s*(?P<flags>[\\w-]+(=\\w+)?(,\\s*\\w+(=\\w+)?)*)\\s*\\])?')\ndef safe_get_entry(spec):\n    if ('[' in spec or ']' in spec) and not ENTRY_RE.search(spec):\n        raise ValueError('malformed entry-point flags: %r' % spec)\n    from distlib.util import get_export_entry\n    return get_export_entry(spec)","typeGuard":null,"tryCatchPattern":"from distlib.util import get_export_entry, DistlibException\ntry:\n    entry = get_export_entry(spec)\nexcept DistlibException as e:\n    if 'Invalid specification' in str(e):\n        report_bad_entry_point(spec)\n    else:\n        raise","preventionTips":["Validate entry_point specs against the canonical 'name = module:attr [flags]' form.","Keep flags in a single trailing bracket group with legal characters only.","Lint entry_points tables during CI."],"tags":["entry-point","packaging","metadata","parsing","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}