Skip to content

Rollbar interprets empty tuple in 'server.history.args' as a CircularReference  #402

@ezra-agathos

Description

@ezra-agathos

System: macOS Catalina 10.15.7
Python: 3.6.13
Rollbar: 0.15.0

Problem

We use pyrollbar to capture error/exception information on python modules which run as jobs. On rollbar, we are seeing many reports that show something like this:

{
    "body": {
        ...
        "server": {
           ...,
            "history": [
                  {
                    "timestamp": 1643242402.460253, 
                    "args": [], 
                    "format": "script args: ***********"
                  }, 
                  {
                    "timestamp": 1643242416.966411, 
                    "args": [], 
                    "format": "*********"
                  }, 
                  {
                    "timestamp": 1643242428.563935, 
                    "args": "<CircularReference type:(tuple) ref:(server.history.1.args)>", 
                    "format": "**********"
                  },
                  ...
             ],
             ...
         },
         ...
     }
}

Below is the code that sets up the logger:

...
 if settings.ROLLBAR_API_KEY:
        rollbar.init(
            settings.ROLLBAR_API_KEY,
            settings.ROLLBAR_ENVIRONMENT,
            scrub_fields=settings.ROLLBAR_SCRUB_FIELDS,
        )
        # Send to rollbar all WARNING or higher logs
        rollbar_warn_logger = rollbar.logger.RollbarHandler()
        rollbar_warn_logger.setLevel(logging.WARNING)
        rollbar_warn_logger.addFilter(f)
        log.addHandler(rollbar_warn_logger)
        ...

Expectation

From what I understand, our code throws exceptions without any additional arguments. I would have expected that all instances of () would have been interpreted to a [] when converted to rolllbar payload.

Additional Information

The data is transformed to payload in _build_payload (line 1339, rollbar/init.py). Stepping through this, I noticed that the data didn't have any CircularReferences until after transformation via traverse (line 88 rollbar/lib/traverse.py). It appears that the id function is used to hash the key argument to a unique identifier inside memo. However, the id function will always return the same value for an empty tuple input. I couldn't find documentation on how to properly add an empty tuple to an allowed circular types - though I think this issue may be somewhat similar?: #286

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions