Skip to content

Poor error when calling sentry_sdk.init with too much *args #1178

@touilleMan

Description

@touilleMan

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
sentry_sdk for python version 1.3.1

Steps to Reproduce

>>> import sentry_sdk
>>> sentry_sdk.VERSION
'1.3.1'
>>> sentry_sdk.init(None, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emmanuel/projects/parsec-cloud/venv/lib/python3.8/site-packages/sentry_sdk/hub.py", line 105, in _init
    client = Client(*args, **kwargs)  # type: ignore
  File "/home/emmanuel/projects/parsec-cloud/venv/lib/python3.8/site-packages/sentry_sdk/client.py", line 84, in __init__
    self.options = get_options(*args, **kwargs)  # type: Dict[str, Any]
  File "/home/emmanuel/projects/parsec-cloud/venv/lib/python3.8/site-packages/sentry_sdk/client.py", line 51, in _get_options
    options = dict(*args, **kwargs)
TypeError: 'int' object is not iterable
>>> sentry_sdk.init(None, 1, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emmanuel/projects/parsec-cloud/venv/lib/python3.8/site-packages/sentry_sdk/hub.py", line 105, in _init
    client = Client(*args, **kwargs)  # type: ignore
  File "/home/emmanuel/projects/parsec-cloud/venv/lib/python3.8/site-packages/sentry_sdk/client.py", line 84, in __init__
    self.options = get_options(*args, **kwargs)  # type: Dict[str, Any]
  File "/home/emmanuel/projects/parsec-cloud/venv/lib/python3.8/site-packages/sentry_sdk/client.py", line 51, in _get_options
    options = dict(*args, **kwargs)
TypeError: dict expected at most 1 argument, got 2

Expected Result

Client.__init__ should raise an explicit TypeError exception about the fact it only accept one non-kwargs argument.

Actual Result

Currently the client crash due to an improper usage of dict:

options = dict(*args, **kwargs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions