openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

🐛 Bug Report: AttributeError on import of newer version of traceloop.sdk

Open baldeoa opened this issue 1 year ago • 1 comments

Which component is this bug for?

Traceloop SDK

📜 Description

The installed_packages in packages/traceloop-sdk/traceloop/sdk/utils/package_check.py assuming that every distribution's metadata contains a "Name" entry. If a distribution's metadata is missing this entry (or if it is None), attempting to call .lower() on None will result in an AttributeError. This error was not present in older versions of traceloop-sdk and started happening when upgrading to version 34 and above

👟 Reproduction steps

from traceloop.sdk import Instruments

👍 Expected behavior

installed_packages = {
    dist.metadata.get("Name", "").lower()
    for dist in distributions()
    if dist.metadata.get("Name") is not None
} 

👎 Actual Behavior with Screenshots

  File "/app/venv/lib/python3.11/site-packages/traceloop/sdk/utils/package_check.py", line 3, in <setcomp>
    installed_packages = {dist.metadata["Name"].lower() for dist in distributions()}
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'

🤖 Python Version

3.11

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • [x] I checked and didn't find similar issue

Are you willing to submit PR?

None

baldeoa avatar Feb 03 '25 20:02 baldeoa

Fixed by #2607

doronkopit5 avatar Feb 06 '25 09:02 doronkopit5