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

Value of trace_configs might be None #1592

Merged

Conversation

estheruary
Copy link
Contributor

@estheruary estheruary commented Jan 22, 2023

Description

Ran into this in the wild, trace_configs might be None.

future: <Task finished name='Task-1' coro=<Client.start() done, defined at /Users/---/.pyenv/versions/---/lib/python3.11/site-packages/discord/client.py:724> exception=TypeError("'NoneType' object is not iterable")>
Traceback (most recent call last):
  File "/Users/---/.pyenv/versions/---/lib/python3.11/site-packages/discord/client.py", line 745, in start
    await self.login(token)
  File "/Users/---/.pyenv/versions/---/lib/python3.11/site-packages/discord/client.py", line 580, in login
    data = await self.http.static_login(token)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/---/.pyenv/versions/---/lib/python3.11/site-packages/discord/http.py", line 789, in static_login
    self.__session = aiohttp.ClientSession(
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/---/.pyenv/versions/---/lib/python3.11/site-packages/opentelemetry/instrumentation/aiohttp_client/__init__.py", l
ine 283, in instrumented_init
    client_trace_configs = list(kwargs.get("trace_configs", ()))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
trace_configs is Optional[Sequence]

None -> kwargs.get("trace_configs", ()) == None --> TypeError

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@estheruary estheruary requested a review from a team January 22, 2023 23:45
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 22, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: estheruary / name: Estelle Poulin (8b9edd1)

@@ -280,7 +280,7 @@ def instrumented_init(wrapped, instance, args, kwargs):
if context_api.get_value(_SUPPRESS_INSTRUMENTATION_KEY):
return wrapped(*args, **kwargs)

client_trace_configs = list(kwargs.get("trace_configs", ()))
client_trace_configs = list(kwargs["trace_configs"] or [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If trace_configs did not exist in kwargs the code throws a KeyError exception, so you need to verify this and use kwargs.get().

client_trace_configs = list(kwargs.get("trace_configs") or [])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@srikanthccv
Copy link
Member

Please add CHANGELOG entry

@estheruary
Copy link
Contributor Author

Please add CHANGELOG entry

Done!

@srikanthccv srikanthccv enabled auto-merge (squash) January 31, 2023 10:18
@srikanthccv srikanthccv merged commit 6ed2c56 into open-telemetry:main Jan 31, 2023
@nemoshlag
Copy link
Member

Thanks @estheruary for fixing my bug 🙏

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 this pull request may close these issues.

4 participants