Skip to content

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

Closed

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)

Activity

  1. github-actions commented on Dec 23, 2021

    @github-actions
    Contributor

    This issue has gone three weeks without activity. In another week, I will close it.

    But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


    "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

  2. antonpirker commented on Feb 23, 2022

    @antonpirker
    Contributor

    Hey @touilleMan
    Thanks for writing in. Yes, here the error message could be way better, I agree.
    We will put in on our internal Backelog. (But our backlog right now is quite big, so please don't hold your breath on it! :-))

  3. targhs commented on Mar 5, 2022

    @targhs
    Contributor

    Added a PR #1361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions