snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.21k stars 3.2k forks source link

[6.0.3] Trying to access array offset on value of type null at .../Transformers/AssetsTransformer.php #11304

Closed hdering closed 2 years ago

hdering commented 2 years ago

Debug mode

Describe the bug

After upgrade to 6.0.3 the view all assets is empty.

The following errors are displayed: `[2022-06-14 07:24:33] production.ERROR: Trying to access array offset on value of type null {"userId":695,"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at /var/www/html/snipeit/app/Http/Transformers/AssetsTransformer.php:121) Stack trace:

0 /var/www/html/snipeit/app/Http/Transformers/AssetsTransformer.php(121): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()

1 /var/www/html/snipeit/app/Http/Transformers/AssetsTransformer.php(17): App\Http\Transformers\AssetsTransformer->transformAsset()

2 /var/www/html/snipeit/app/Http/Controllers/Api/AssetsController.php(353): App\Http\Transformers\AssetsTransformer->transformAssets()

3 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\Api\AssetsController->index()

4 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction()

5 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\Routing\ControllerDispatcher->dispatch()

6 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\Routing\Route->runController()

7 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\Routing\Route->run()

8 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing{closure}()

9 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(127): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

10 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(63): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest()

11 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\ThrottleRequests->handle()

12 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

13 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Auth\Middleware\Authenticate->handle()

14 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

15 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Pipeline\Pipeline->then()

16 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router->runRouteWithinStack()

17 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router->runRoute()

18 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router->dispatchToRoute()

19 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Routing\Router->dispatch()

20 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}()

21 /var/www/html/snipeit/vendor/livewire/livewire/src/DisableBrowserCache.php(19): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

22 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Livewire\DisableBrowserCache->handle()

23 /var/www/html/snipeit/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

24 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()

25 /var/www/html/snipeit/vendor/fruitcake/laravel-cors/src/HandleCors.php(52): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

26 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle()

27 /var/www/html/snipeit/app/Http/Middleware/PreventBackHistory.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

28 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\PreventBackHistory->handle()

29 /var/www/html/snipeit/app/Http/Middleware/SecurityHeaders.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

30 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\SecurityHeaders->handle()

31 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

32 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()

33 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()

34 /var/www/html/snipeit/app/Http/Middleware/CheckForDebug.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

35 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\CheckForDebug->handle()

36 /var/www/html/snipeit/app/Http/Middleware/CheckForSetup.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

37 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\CheckForSetup->handle()

38 /var/www/html/snipeit/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

39 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle()

40 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

41 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle()

42 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

43 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest()

44 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle()

45 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

46 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()

47 /var/www/html/snipeit/app/Http/Middleware/NoSessionStore.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

48 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\NoSessionStore->handle()

49 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}()

50 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then()

51 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()

52 /var/www/html/snipeit/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle()

53 {main} `

`[2022-06-14 07:24:33] production.ERROR: ErrorException: Trying to access array offset on value of type null in /var/www/html/snipeit/app/Http/Transformers/AssetsTransformer.php:121#44 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle()

45 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

46 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()

47 /var/www/html/snipeit/app/Http/Middleware/NoSessionStore.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

48 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\NoSessionStore->handle()

49 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()

50 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then()

51 /var/www/html/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()

52 /var/www/html/snipeit/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle()

53 {main}

"} `

Reproduction steps

  1. Select "show all assets"

Expected behavior

All assets are displayed to me.

Screenshots

No response

Snipe-IT Version

6.0.3

Operating System

Ubuntu 18.04

Web Server

Apache

PHP Version

8.1.6

Operating System

Windows

Browser

Google Chrome

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

If I enter an asset name in the search field, the result is shown to me.

inietov commented 2 years ago

Thanks for the report! A possible fix is in the way.

snipe commented 2 years ago

@hdering can you do a fresh pull from master and let us know if that fixes you?

hdering commented 2 years ago

Works again. Thanks :).

snipe commented 2 years ago

Hah - this might be a new record for tagging a new release - 25 minutes! :P

Thanks for the late night quick fix, @inietov :)

inietov commented 2 years ago

I'm nothing without my community. (also I was the one introducing the bug, code was fresh in my mind)