Skip to content

BUG: ValueError crashes sentry_sdk.init() when functions_to_trace entry has no dot in qualified_name #6451

@devteamaegis

Description

@devteamaegis

What breaks

Calling sentry_sdk.init() with a functions_to_trace entry whose qualified_name contains no dot (e.g. "my_function") raises an unhandled ValueError that prevents SDK initialization entirely.

sentry_sdk.init(
    dsn="https://key@sentry.io/123",
    functions_to_trace=[{"qualified_name": "my_function"}],
    traces_sample_rate=1.0,
)
# ValueError: not enough values to unpack (expected 2, got 1)

Traceback

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)

Root cause

In _setup_instrumentation(), the call module_name, function_name = function_qualname.rsplit(".", 1) at line 510 sits before the try/except block that starts at line 512. When qualified_name has no dot, rsplit returns a single-element list, the 2-target unpacking raises ValueError, and because it is outside the try block the exception propagates all the way out of sentry_sdk.init().

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions