…tation (getsentry#6452)
## What's broken
Passing a `functions_to_trace` entry whose `qualified_name` has no dot
(e.g. `{"qualified_name": "my_function"}`) crashes `sentry_sdk.init()`
with an unhandled `ValueError`. The SDK never initializes and the user
gets a hard traceback instead of a warning.
```
File "sentry_sdk/client.py", line 510, in _setup_instrumentation
module_name, function_name = function_qualname.rsplit(".", 1)
ValueError: not enough values to unpack (expected 2, got 1)
```
## Why it happens
The `rsplit(".", 1)` unpacking on line 510 sits **before** the
`try/except` block that begins on line 512. When `qualified_name`
contains no dot, the list has one element, the two-target unpacking
fails, and the `ValueError` propagates out of `__init__` uncaught.
## Fix
Added a guard before the `rsplit` call: if `"."` is not in
`function_qualname`, log a warning and `continue` to the next entry. The
user gets a clear message to use a fully qualified name (e.g.
`mymodule.my_function`) and SDK init proceeds normally.
## Test
`test_functions_to_trace_no_dot_does_not_crash` — verifies that
`sentry_sdk.init()` with a dot-free `qualified_name` completes without
raising.
Fixes getsentry#6451
Co-authored-by: Aegis Dev <devteamaegis@users.noreply.github.com>
Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
What's broken
Passing a functions_to_trace entry whose qualified_name has no dot (e.g. {"qualified_name": "my_function"}) crashes sentry_sdk.init() with an unhandled ValueError. The SDK never initializes and the user gets a hard traceback instead of a warning.
File "sentry_sdk/client.py", line 510, in _setup_instrumentation module_name, function_name = function_qualname.rsplit(".", 1) ValueError: not enough values to unpack (expected 2, got 1)Why it happens
The rsplit(".", 1) unpacking on line 510 sits before the try/except block that begins on line 512. When qualified_name contains no dot, the list has one element, the two-target unpacking fails, and the ValueError propagates out of __init__ uncaught.
Fix
Added a guard before the rsplit call: if "." is not in function_qualname, log a warning and continue to the next entry. The user gets a clear message to use a fully qualified name (e.g. mymodule.my_function) and SDK init proceeds normally.
Test
test_functions_to_trace_no_dot_does_not_crash — verifies that sentry_sdk.init() with a dot-free qualified_name completes without raising.
Fixes #6451