Treblle / treblle-laravel

The official Treblle SDK for Laravel. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.
https://www.treblle.com/
MIT License
129 stars 21 forks source link

ErrorException: Undefined array key 1 in FieldMasker.php #79

Closed iRajul closed 1 year ago

iRajul commented 1 year ago

Version

Description

I am getting following error after installing treblle , following in rollbar stack.

ErrorException: Undefined array key 1
  File "/var/www/html/app/vendor/treblle/utils/src/Masking/FieldMasker.php", line 54
  File "/var/www/html/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php", line 254, in Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
  File "/var/www/html/app/vendor/treblle/utils/src/Masking/FieldMasker.php", line 54, in Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}
  File "/var/www/html/app/vendor/treblle/treblle-laravel/src/Factories/DataFactory.php", line 95, in Treblle\Utils\Masking\FieldMasker::mask
  File "/var/www/html/app/vendor/treblle/treblle-laravel/src/Middlewares/TreblleMiddleware.php", line 82, in Treblle\Factories\DataFactory::make
  File "/var/www/html/app/treblle/treblle-laravel/src/Middlewares/TreblleMiddleware.php", line 55, in Treblle\Middlewares\TreblleMiddleware::collectData
  File "/var/www/html/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", line 258, in Treblle\Middlewares\TreblleMiddleware::terminate
  File "/var/www/html/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", line 213, in Illuminate\Foundation\Http\Kernel::terminateMiddleware
  File "/var/www/html/app/public/index.php", line 55, in Illuminate\Foundation\Http\Kernel::terminate

Explain the context and how you encountered this bug. I am getting this error on particular API. I am not sure the reason.

treblle.php

<?php

return [
    /*
     * A valid Treblle API key. You can get started for FREE by visiting https://treblle.com/
     */
    'api_key' => env('TREBLLE_API_KEY'),

    /*
     * A valid Treblle project ID. Create your first project on https://treblle.com/
     */
    'project_id' => env('TREBLLE_PROJECT_ID'),

    /*
     * Define which environments should Treblle ignore and not monitor
     */
    'ignored_environments' => env('TREBLLE_IGNORED_ENV', 'dev,test,testing'),

    /*
     * Define which fields should be masked before leaving the server
     */
    'masked_fields' => [
        'password',
        'pwd',
        'secret',
        'password_confirmation',
        'cc',
        'card_number',
        'ccv',
        'ssn',
        'credit_score',
        'api_key',
        'api_token'
    ],
];

More details :

Treblle\Utils\Masking\FieldMasker::mask(/var/www/html/app/vendor/treblle/treblle-laravel/src/Factories/DataFactory.php:95)
Treblle\Utils\Masking\FieldMasker::mask arguments
{
  "ac": "12",
  "access-control-allow-headers": "*",
  "cf-visitor": "{\"scheme\":\"https\"}",
  "accept-encoding": "gzip, br",
  "content-type": "application/json; charset=utf-8",
  "x-forwarded-for": "2401:4900:8028:40ce::2f:f04",
  "content-length": "",
  "accept": "application/json; charset=utf-8",
  "user-agent": "Dart/2.19 (dart:io)",
  "access-control-allow-origin": "*",
  "host": "",
  "x-forwarded-proto": "https",
  "cache-control": "no-cache",
  "cdn-loop": "cloudflare",
  "cf-connecting-ip": "2401:4900:8088:40ce::2f:f04",
  "cf-ray": "7fddae0a495c9e-FRA",
  "cf-ipcountry": "IN",
  "x-app-user": "customer",
  "x-app-identifier": "",
  "authorization": "Bearer"
}

Steps to reproduce

  1. ...
  2. ...
  3. ...

Expected behavior

Explain what result you expected to see.

Notes

Any additional useful informations, like related issues, ...

chris-treblle commented 1 year ago

Hi Rajul, We've raised a fix in 4.2.0 for this - could you confirm this is now working for you?

iRajul commented 1 year ago

Yes it working now. Thanks.