Skip to content

New TelemetryEvent cannot handle nested array as $body argument #648

Closed

Description

@screambeard

I'm using the newest release of the Laravel PHP package which uses the 4.1.0 version of this package. This version can result in the following error:

Named parameter $message overwrites previous argument {"exception":"[object] (Error(code: 0): Named parameter $message overwrites previous argument at vendor/rollbar/rollbar/src/Payload/TelemetryEvent.php:50)

This error is thrown if the body argument of the TelemetryEvent __construct function is a nested array. For example (when using the Laravel-Rollbar package):

Log::info('This throws an error', [["data" => "some data]]);

The error is caused by the top-level nested array. This worked before, so this is regression of functionality.

Simple replication
To replicate you can do the following, which is simple direct replication of what happens in the constructor of the TelemetryEvent class.

// This throws an error
$event = new TelemetryBody(...[['data' => 'some_data']]);

One lever higher up, there is a restriction on what is allowed in the array of the body. The following will cause an error:

new TelemetryEvent(
      EventType::Log,
      EventLevel::Info,
      ["0" => ["id" => "some id"], 'message' => 'test message'],
 );

The above is a simplification of how the TelementryEvent is used within Rollbar-Laravel package: https://github.com/rollbar/rollbar-php-laravel/blob/f430c09887d3603bcefc870fd7a9e7abcd009920/src/TelemetryListener.php#L104 which triggers this issue.

Activity

  1. self-assigned this
    on Mar 21, 2025
  2. added a commit that references this issue on Mar 21, 2025
    78db456
  3. added this to the v4.1.1 milestone on Mar 21, 2025
  4. added theissue type on Mar 21, 2025
  5. added a commit that references this issue on Mar 21, 2025
    3d7f993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions