snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

A specific asset fails to display its 'view asset' page

Open ghost opened this issue 10 years ago • 20 comments

Expected Behavior (or desired behavior if a feature request)

This is just on one particular asset, out the blue, but possibly linked to the user somehow.

Click on asset tag to view it and the asset information screen is displayed.


Actual Behavior

It loads part of the page then displays an exception error. The partly displayed page is not styled.

FatalErrorException in c23e1f397081f08a96f5b7244cfad1110445da61.php line 673:

Call to a member function fullName() on null


Please confirm you have done the following before posting your bug report:


Please provide answers to these questions before posting your bug report:

  • Version of Snipe-IT you're running - 3.6
  • What OS and web server you're running Snipe-IT on - IIS8
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) - manual
  • WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error.

Whoops, looks like something went wrong.

1/1

FatalErrorException in c23e1f397081f08a96f5b7244cfad1110445da61.php line 673:

Call to a member function fullName() on null

  1. in c23e1f397081f08a96f5b7244cfad1110445da61.php line 673
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error - http://snipeit/hardware/1042/view

  • If a stacktrace is provided in the error, include that too.

  • Any errors that appear in your browser's error console.

  • Confirm whether the error is reproduceable on the demo. - No

  • Include any additional information you can find in app/storage/logs and your webserver's logs. - none different to what I've shown.

  • Include what you've done so far in the installation, and if you got any error messages along the way.

  • Indicate whether or not you've manually edited any data directly in the database - No.

ghost avatar Nov 17 '16 16:11 ghost

Is there anything unusual about that asset? Was it deleted or anything?

snipe avatar Nov 18 '16 05:11 snipe

Also, can you show me the lines around 23e1f397081f08a96f5b7244cfad1110445da61.php line 673? A few above and a few below.

snipe avatar Nov 18 '16 05:11 snipe

Renaming/removing the file in /storage/framework/views won't help?

diekmanu avatar Nov 18 '16 06:11 diekmanu

that bug for me shows up after "signature" was enabled.

  • it usually happens after asset was "signed" by the user and when you try to edit / save settings of that asset then that bug kicks in.
  • for me removing the file ( asset ) helps but then you lose all the history so that is not a solution
  • I will try to test it today and submit code that you requested

I have written about that in a topic concerning asset acceptance and sig_filename

ghost avatar Nov 21 '16 08:11 ghost

Lines 670 - 676:

<?php else: ?>
                                <del><?php echo e($log->target->showAssetName()); ?></del>
                              <?php endif; ?>
                            <?php elseif(($log->action_type=='accepted') || ($log->action_type=='declined')): ?>
                                    <?php echo e($log->item->assigneduser->fullName()); ?>

                            <?php else: ?>

ghost avatar Nov 21 '16 11:11 ghost

As regards anything unusual, this particular asset was checked out to a manually created user, FirstName 'Snipe' , LastName 'test', Could just be a coincidence or there's something it doesn't like about the user somehow. It hasn't been deleted.

ghost avatar Nov 21 '16 11:11 ghost

rozowykubek - the scenario you described tests out fine at my end.

ghost avatar Nov 21 '16 11:11 ghost

rozowykubek - the scenario you described tests out fine at my end.

Actually that's bad but first part of your scenario matches mine that is "checked out to user". Although once it happened after asset was checked in.

Do you have signature feature enabled when it happens ? cause I don't have that issue with signature turned off ( fresh installation - 2 users nothing more )

ghost avatar Nov 21 '16 12:11 ghost

@mmcleod82 Can you find the DB record with that entry in the action_logs table?

snipe avatar Nov 22 '16 02:11 snipe

yes I've found the DB records for that asset - what are you interested in?

ghost avatar Nov 23 '16 14:11 ghost

capture1 capture2

ghost avatar Nov 23 '16 14:11 ghost

Can you tell if it's the update that it's choking on?

snipe avatar Nov 23 '16 14:11 snipe

Well, when I've seen this happen once before, it chokes during checking in (it does checkin though), then on subsequent attempts to view the asset.

ghost avatar Nov 23 '16 15:11 ghost

the line with id 4472 looks like the culprit to me. It has a target_id set, but not a target type...

mnemonicly avatar Nov 24 '16 00:11 mnemonicly

Does changing the target_type on that line to App\Models\User fix it for you? It's a missing line in ViewAssetsController, I'll need to do something to retrofit it, but this should fix future issues.

diff --git a/app/Http/Controllers/ViewAssetsController.php b/app/Http/Controllers/ViewAssetsController.php
index 6febfd5..acbe21b 100755
--- a/app/Http/Controllers/ViewAssetsController.php
+++ b/app/Http/Controllers/ViewAssetsController.php
@@ -379,6 +379,7 @@ class ViewAssetsController extends Controller
         }

         $logaction->target_id = $findlog->target_id;
+        $logaction->target_type = User::class;
         $logaction->note = e(Input::get('note'));
         $logaction->updated_at = date("Y-m-d H:i:s");

mnemonicly avatar Nov 24 '16 01:11 mnemonicly

Well, that's a different bug actually. I can't reproduce what you are seeing here..

mnemonicly avatar Nov 24 '16 16:11 mnemonicly

ok, shall I just try changing the target_type on that line to App\Models\User anyway?

If not, is there anything dirty you can do to allow it to display?

ghost avatar Nov 24 '16 16:11 ghost

You can try changing the target type, but I don't think it will fix this issue...

I can see why an issue would appear if the checkout was declined, but it doesn't look like that is in your table.

mnemonicly avatar Nov 24 '16 16:11 mnemonicly

Oh yes, now I see. Changing the target type will fix it. Those lines are only hit if we don't have a target.

mnemonicly avatar Nov 24 '16 16:11 mnemonicly

Yes, setting the target_type worked. What might of caused it not to be set then do you think?

ghost avatar Nov 24 '16 16:11 ghost