Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#339 / v4.8.0 broke stevedore which broke bandit, openstackclient, flake8 and others #348

Closed
mr-c opened this issue Aug 29, 2021 · 16 comments · Fixed by #349
Closed

#339 / v4.8.0 broke stevedore which broke bandit, openstackclient, flake8 and others #348

mr-c opened this issue Aug 29, 2021 · 16 comments · Fixed by #349

Comments

@mr-c
Copy link

mr-c commented Aug 29, 2021

Hello, #339 in v4.8.0 broke stevedore which broke bandit for at least myself (but probably others)

https://github.com/common-workflow-language/cwltool/pull/1482/checks?check_run_id=3454232416#step:9:50
PyCQA/bandit#730

Reverting to importlib_metadata version 4.7.1 resolves the problem for me

Originally posted by @mr-c in #339 (comment)

@Stannislav
Copy link

Stannislav commented Aug 29, 2021

Same

$ bandit
Traceback (most recent call last):
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/_cache.py", line 159, in _get_data_for_path
    with open(filename, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/me/Library/Caches/Python Entry Points/f02c0770d01da06fbfcfe6435c8feb2e12f0e5fb7e239f6cf91d4d8d088821d8'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/me/project/.tox/lint/bin/bandit", line 5, in <module>
    from bandit.cli.main import main
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/bandit/__init__.py", line 19, in <module>
    from bandit.core import config  # noqa
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/bandit/core/__init__.py", line 17, in <module>
    from bandit.core import config  # noqa
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/bandit/core/config.py", line 12, in <module>
    from bandit.core import extension_loader
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/bandit/core/extension_loader.py", line 109, in <module>
    MANAGER = Manager()
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/bandit/core/extension_loader.py", line 25, in __init__
    self.load_formatters(formatters_namespace)
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/bandit/core/extension_loader.py", line 33, in load_formatters
    verify_requirements=False,
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/extension.py", line 136, in __init__
    verify_requirements)
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/extension.py", line 218, in _load_plugins
    for ep in self.list_entry_points():
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/extension.py", line 207, in list_entry_points
    eps = list(_cache.get_group_all(self.namespace))
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/_cache.py", line 179, in get_group_all
    data = self._get_data_for_path(path)
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/_cache.py", line 162, in _get_data_for_path
    data = _build_cacheable_data(path)
  File "/Users/me/project/.tox/lint/lib/python3.7/site-packages/stevedore/_cache.py", line 119, in _build_cacheable_data
    item = ep[:]  # convert namedtuple to tuple
TypeError: 'EntryPoint' object is not subscriptable

@freedge
Copy link

freedge commented Aug 29, 2021

Seems to break openstack cli and rally testing as well. Opening https://storyboard.openstack.org/#!/story/2009151

@mr-c mr-c changed the title #339 / v4.8.0 broke stevedore which broke bandit #339 / v4.8.0 broke stevedore which broke bandit & openstackclient Aug 29, 2021
@WilliamDEdwards
Copy link

WilliamDEdwards commented Aug 29, 2021

Same here with flake8 (uses stevedore). I created a stevedore bug here: https://bugs.launchpad.net/python-stevedore/+bug/1941991

@jaraco
Copy link
Member

jaraco commented Aug 29, 2021

Sorry for the inconvenience. I've yanked 4.8.0 while working out a remedy.

mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Aug 29, 2021
The recent release of importlib-metadata has broken an interface that
stevedore uses when looking for entrypoints (see
python/importlib_metadata#348 ). Several of
our test/ci dependecies use stevedore for their plugin interfaces
including stestr which is causing CI failures. To unblock CI this commit
pins the importlib metadata version in our constraints file while the
upstream issue is resolved.
mtreinish added a commit to mtreinish/retworkx that referenced this issue Aug 29, 2021
The recent release of importlib-metadata has broken an interface that
stevedore uses when looking for entrypoints (see:
python/importlib_metadata#348 ). Several of
our test/ci dependecies use stevedore for their plugin interfaces
including stestr which is causing CI failures. To unblock CI this commit
pins the importlib metadata version in our constraints file while the
upstream issue is resolved.
@jaraco
Copy link
Member

jaraco commented Aug 29, 2021

I'd like devise a way to capture these requirements. I can see from the failure that stevedore is expecting __getitem__(slice) to return a tuple, something that namedtuple (or other tuple) would do implicitly.

@jaraco
Copy link
Member

jaraco commented Aug 29, 2021

@mtreinish: You may wish to refrain from pinning too many projects as I've yanked the offending version and expect to release the next version without the broken behavior.

@mr-c
Copy link
Author

mr-c commented Aug 29, 2021

Sorry for the inconvenience. I've yanked 4.8.0 while working out a remedy.

Thanks for the quick yank! I know this isn't nice news to receive.

@mr-c mr-c changed the title #339 / v4.8.0 broke stevedore which broke bandit & openstackclient #339 / v4.8.0 broke stevedore which broke bandit, openstackclient, flake8 and others Aug 29, 2021
@jaraco
Copy link
Member

jaraco commented Aug 29, 2021

In #349, I've drafted a fix but marking the access by item as deprecated. I can add other missing but expected tuple behaviors there as well if needed. I welcome feedback.

@jaraco
Copy link
Member

jaraco commented Aug 29, 2021

v4.8.1 is releasing now. I believe this addresses the issue. It's possible there are other usages out there dependent on tuple behaviors. If so, please raise an issue, mention me, and I'll address those promptly.

halstead pushed a commit to openembedded/openembedded-core that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
kraj pushed a commit to YoeDistro/poky-old that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
armcc pushed a commit to lgirdk/poky that referenced this issue Oct 13, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 01eb9d4384ae78b02780cea3b8690d99484b2602)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
splitice pushed a commit to HalleyAssist/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 4272ca45d137b91ec368c94b3e0dbd7d56c616dd)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
seambot pushed a commit to seamapi/poky that referenced this issue Oct 14, 2021
v4.8.1
  #348: Restored support for EntryPoint access by item, deprecating
        support in the process. Users are advised to use direct member
        access instead of item-based access:

    - ep[0] -> ep.name
    - ep[1] -> ep.value
    - ep[2] -> ep.group
    - ep[:] -> ep.name, ep.value, ep.group

v4.8.0
  #337: Rewrote EntryPoint as a simple class, still immutable and
        still with the attributes, but without any expectation for
        namedtuple functionality such as _asdict.

v4.7.1
  #344: Fixed regression in packages_distributions when neither
        top-level.txt nor a files manifest is present.

v4.7.0
  #330: In packages_distributions, now infer top-level names from
        .files() when a top-level.txt (Setuptools-specific metadata)
        is not present.

References:
  python/importlib_metadata#348
  python/importlib_metadata#337
  python/importlib_metadata#344
  python/importlib_metadata#330

(From OE-Core rev: 21d72ace8f9486bd1b478e28d53da64087d790fa)

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
@jacwalte
Copy link

jacwalte commented Oct 3, 2022

Looks like this issue has been reintroduced in v5.0.0.

We are seeing all pipelines fail this morning with the same message when using bandit for security linting.

Traceback (most recent call last):
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/_cache.py", line 159, in _get_data_for_path
    with open(filename, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/python-entrypoints/3a36feec8a00a8eb17dbba25d793c41a65191f1d2d9320a96f6605c8d32530be'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/miniconda/envs/.../bin/bandit", line 5, in <module>
    from bandit.cli.main import main
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/bandit/__init__.py", line 7, in <module>
    from bandit.core import config  # noqa
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/bandit/core/__init__.py", line 5, in <module>
    from bandit.core import config  # noqa
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/bandit/core/config.py", line 15, in <module>
    from bandit.core import extension_loader
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/bandit/core/extension_loader.py", line 109, in <module>
    MANAGER = Manager()
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/bandit/core/extension_loader.py", line 21, in __init__
    self.load_formatters(formatters_namespace)
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/bandit/core/extension_loader.py", line 29, in load_formatters
    verify_requirements=False,
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/extension.py", line 136, in __init__
    verify_requirements)
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/extension.py", line 218, in _load_plugins
    for ep in self.list_entry_points():
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/extension.py", line 207, in list_entry_points
    eps = list(_cache.get_group_all(self.namespace))
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/_cache.py", line 179, in get_group_all
    data = self._get_data_for_path(path)
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/_cache.py", line 162, in _get_data_for_path
    data = _build_cacheable_data(path)
  File "/usr/local/miniconda/envs/.../lib/python3.7/site-packages/stevedore/_cache.py", line 110, in _build_cacheable_data
    for name, group_data in real_groups.items():
AttributeError: 'EntryPoints' object has no attribute 'items'

@jaraco
Copy link
Member

jaraco commented Oct 3, 2022

I'm not confident of the report above for a couple of reasons.

First, the report doesn't include the actual error message. It includes a screenshot with only a FileNotFoundError.

Second, the issue reported above was addressed in 4.8.1, but the changes made in the 5.0 release were made against 5fb7029, released in 4.4.0.

Most importantly, importlib_metadata 5 still retains the tuple item access support (deprecated) added in v4.8.1.

Probably the user is reporting the issue reported in #409.

@jacwalte
Copy link

jacwalte commented Oct 3, 2022

@jaraco I updated my comment with the full content of the error provided by the ADO (Azure Dev Ops) task.

commands that ran the task.

source $CONDA/bin/activate
python -m pip install safety==2.1.1 bandit==1.7.4
safety check
bandit --recursive .

We were not specifying the version of importlib-metadata or that it be installed here. I updated the python -m pip command to include importlib-metadata==4.13.0 and now everything is passing as expected.

new command

source $CONDA/bin/activate
python -m pip install importlib-metadata==4.13.0 safety==2.1.1 bandit==1.7.4
safety check
bandit --recursive .

Please let me know if I can provide more details.

Thanks!
Jack Walters

@jaraco
Copy link
Member

jaraco commented Oct 3, 2022

Thanks. Yes, I can confirm with that traceback that it's a different issue, the one reported in #409, and that this issue could still potentially affect stevedore too, if the deprecation isn't addressed.

@devturner

This comment was marked as off-topic.

@jaraco
Copy link
Member

jaraco commented Oct 4, 2022

@devturner Your issue is in #409.

@jaraco
Copy link
Member

jaraco commented Oct 4, 2022

In 1343876, I've added a note to block the removal of the DeprecatedTuple, which deprecates the item access of an EntryPoint, until 2023-05-01 based on feedback in #409.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants