Skip to content

RecursionError when there are log attributes assigned to None #3578

@OS-joaocastilho

Description

@OS-joaocastilho

Describe your environment:

Python version: 3.10

Steps to reproduce:

Inject attributes assigned to None into LogRecord in a LogRecordFactory.
(logging.LogRecord) record.custom_attribute = None

What is the expected behavior?
The SDK should handle the injection of attributes assigned to None into LogRecord without entering into a recursion loop.

What is the actual behavior?
The SDK enters a recursion loop, leading to a RecursionError, causing the service to die.

Additional context:

This issue occurs when injecting attributes assigned to None into the LogRecord in a LogRecordFactory that will be consumed by the SDK Logs.
The problem is specifically in the _clean_attribute method of the BoundedAttributes class, which generates a new logger.warning and leads to an infinite loop when the attribute is assigned as None.
While a workaround is possible on the service side by removing the None attribute, it is essential to address this issue in the SDK to prevent the logging module from causing service failures.
](log_record1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglogging

    Type

    No type

    Projects

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions