snipe / snipe-it

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

Unable to import assets list - ERROR Trying to get property of non-object #6190

Closed tekkitan closed 5 years ago

tekkitan commented 6 years ago

I am reposting this issue (https://github.com/snipe/snipe-it/issues/4942) because the issue was hijacked and closed without any actual assistance being given. This was posted by a previous admin in my company and I have taken over the project and stuck in the same spot.

Expected Behavior (or desired behavior if a feature request) Import is successful and all assets appear in the dashboard of the web GUI with proper fields (specifically "name" of user, which is supposed to be parsed as "firstname lastname")

Actual Behavior Import is not successful. I get the following error: user@snipe:/var/www/inventory# php artisan snipe:import Revised_Assets_csv_list.csv --verbose ======= Importing Items from Revised_Assets_csv_list.csv ========= Found a match in our custom map: category is category Custom Key: category A matching category: Laptops already exists Found a match in our custom map: company is company Custom Key: company Found a match in our custom map: location is location Custom Key: location Found a match in our custom map: manufacturer is manufacturer Custom Key: manufacturer Manufacturer Apple already exists Found a match in our custom map: status is status Custom Key: status A matching Status Assigned already exists Found a match in our custom map: supplier is supplier Custom Key: supplier Found a match in our custom map: item_name is item name Custom Key: item name Found a match in our custom map: notes is notes Custom Key: notes Found a match in our custom map: order_number is order number Custom Key: order number Found a match in our custom map: purchase_cost is purchase cost Custom Key: purchase cost Found a match in our custom map: purchase_date is purchase date Custom Key: purchase date Custom Key: quantity Found a match in our custom map: requestable is requestable Custom Key: requestable Custom Key: serial Found a match in our custom map: name is name Custom Key: name Found a match in our custom map: email is email Custom Key: email Found a match in our custom map: username is username Custom Key: username User Kim created Found a match in our custom map: asset_tag is asset tag Custom Key: asset tag No Matching Asset, Creating a new one Found a match in our custom map: image is image Custom Key: image Found a match in our custom map: warranty_months is warranty Custom Key: warranty Found a match in our custom map: asset_model is model name Custom Key: model name Found a match in our custom map: model_number is model number Custom Key: model number A matching model already exists, returning it. Asset with serial number was created

In Loggable.php line 37:

[ErrorException] Trying to get property of non-object

Exception trace: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at /var/www/inventory/app/Models/Loggable.php:37 App\Models\Asset->logCheckout() at /var/www/inventory/app/Models/Asset.php:191 App\Models\Asset->checkOut() at /var/www/inventory/app/Importer/AssetImporter.php:117 App\Importer\AssetImporter->createAssetIfNotExists() at /var/www/inventory/app/Importer/AssetImporter.php:42 App\Importer\AssetImporter->handle() at /var/www/inventory/app/Importer/Importer.php:125 App\Importer\Importer->App\Importer{closure}() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:29 Illuminate\Database\Connection->transaction() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:327 Illuminate\Database\DatabaseManager->call() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221 Illuminate\Support\Facades\Facade::callStatic() at /var/www/inventory/app/Importer/Importer.php:132 App\Importer\Importer->import() at /var/www/inventory/app/Console/Commands/ObjectImportCommand.php:82 App\Console\Commands\ObjectImportCommand->fire() at n/a:n/a call_user_func_array() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container{closure}() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Container/Container.php:539 Illuminate\Container\Container->call() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Console/Command.php:182 Illuminate\Console\Command->execute() at /var/www/inventory/vendor/symfony/console/Command/Command.php:252 Symfony\Component\Console\Command\Command->run() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Console/Command.php:167 Illuminate\Console\Command->run() at /var/www/inventory/vendor/symfony/console/Application.php:936 Symfony\Component\Console\Application->doRunCommand() at /var/www/inventory/vendor/symfony/console/Application.php:240 Symfony\Component\Console\Application->doRun() at /var/www/inventory/vendor/symfony/console/Application.php:148 Symfony\Component\Console\Application->run() at /var/www/inventory/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122 Illuminate\Foundation\Console\Kernel->handle() at /var/www/inventory/artisan:35

HOWEVER...if I change the header in the csv to "Full Name" rather than just "Name" and then run the import on this same csv again, it imports most everything except the "Name" and Serial. It's almost as if it's ignoring it, even though I'm pretty certain that I have the right syntax.

Here's what my csv headers look like:

asset_table

I made sure that there were no trailing spaces at the end of the headers and I made sure that there were no blank lines at the end of the csv. Please confirm you have done the following before posting your bug report: [y] I have enabled debug mode [y] I have read checked the Common Issues page Provide answers to these questions: Is this a fresh install or an upgrade? Fresh install Version of Snipe-IT you're running: v4.6.4 build 3881 Version of PHP you're running: 7.0.30-0ubuntu0.16.04.1 Version of MySQL/MariaDB you're running: MySQL 5.6.37 What OS and web server you're running Snipe-IT on: Ubuntu 16.04 / Apache 2.4.18 What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) git WITH DEBUG TURNED ON, if you're getting an error in your browser, include that error: N/A What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error: N/A If a stacktrace is provided in the error, include that too.: Included above. Any errors that appear in your browser's error console.: N/A Confirm whether the error is reproducible on the demo: https://snipeitapp.com/demo.: N/A Include any additional information you can find in storage/logs and your webserver's logs.: Everything in here is the same info as posted above. Include what you've done so far in the installation, and if you got any error messages along the way.: Nothing out of the ordinary. The install is working fine and I am actually able to import csvs, just not with all of the fields that are expected. Indicate whether or not you've manually edited any data directly in the database: Other than truncate the snipe_assets table to clear the assets, no. Please do not post an issue without answering the related questions above. If you have opened a different issue and already answered these questions, answer them again, once for every ticket. It will be next to impossible for us to help you.

tekkitan commented 6 years ago

[2018-09-25 16:08:03] production.ERROR: ErrorException: Trying to get property of non-object in /var/www/snipe-it/app/Models/Loggable.php:44
Stack trace:
#0 /var/www/snipe-it/app/Models/Loggable.php(44): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/snipe-...', 44, Array)
#1 /var/www/snipe-it/app/Models/Asset.php(249): App\Models\Asset->logCheckout(NULL, Object(App\Models\User))
#2 /var/www/snipe-it/app/Importer/AssetImporter.php(117): App\Models\Asset->checkOut(Object(App\Models\User))
#3 /var/www/snipe-it/app/Importer/AssetImporter.php(41): App\Importer\AssetImporter->createAssetIfNotExists(Array)
#4 /var/www/snipe-it/app/Importer/Importer.php(126): App\Importer\AssetImporter->handle(Array)
#5 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(29): App\Importer\Importer->App\Importer\{closure}(Object(Illuminate\Database\MySqlConnection))
#6 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(327): Illuminate\Database\Connection->transaction(Object(Closure))
#7 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#8 /var/www/snipe-it/app/Importer/Importer.php(133): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#9 /var/www/snipe-it/app/Console/Commands/ObjectImportCommand.php(82): App\Importer\Importer->import()
#10 [internal function]: App\Console\Commands\ObjectImportCommand->fire()
#11 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#12 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#13 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#14 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#15 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#16 /var/www/snipe-it/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#17 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#18 /var/www/snipe-it/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/snipe-it/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\ObjectImportCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/snipe-it/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/snipe-it/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 {main}
[2018-09-25 16:08:03] production.ERROR: ErrorException: Trying to get property of non-object in /var/www/snipe-it/app/Models/Loggable.php:44
Stack trace:
#0 /var/www/snipe-it/app/Models/Loggable.php(44): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/snipe-...', 44, Array)
#1 /var/www/snipe-it/app/Models/Asset.php(249): App\Models\Asset->logCheckout(NULL, Object(App\Models\User))
#2 /var/www/snipe-it/app/Importer/AssetImporter.php(117): App\Models\Asset->checkOut(Object(App\Models\User))
#3 /var/www/snipe-it/app/Importer/AssetImporter.php(41): App\Importer\AssetImporter->createAssetIfNotExists(Array)
#4 /var/www/snipe-it/app/Importer/Importer.php(126): App\Importer\AssetImporter->handle(Array)
#5 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(29): App\Importer\Importer->App\Importer\{closure}(Object(Illuminate\Database\MySqlConnection))
#6 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(327): Illuminate\Database\Connection->transaction(Object(Closure))
#7 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#8 /var/www/snipe-it/app/Importer/Importer.php(133): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#9 /var/www/snipe-it/app/Console/Commands/ObjectImportCommand.php(82): App\Importer\Importer->import()
#10 [internal function]: App\Console\Commands\ObjectImportCommand->fire()
#11 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#12 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#13 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#14 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#15 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#16 /var/www/snipe-it/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#17 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#18 /var/www/snipe-it/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/snipe-it/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\ObjectImportCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/snipe-it/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/snipe-it/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 {main}
snipe commented 6 years ago

Did you make your own CSV, or are you using the sample as a starting point?

tekkitan commented 6 years ago

It's an export from Asset Panda modified to use the snipe importer. We also tried to import the sample csv and it failed to import.

ellisgeek commented 6 years ago

I am also running into this with the command line importer.

I am importing assets from another Snipe Install

Output:

======= Importing Items from ./3050.csv =========
Custom Key: category
A matching category: Computer - Desktop already exists
Custom Key: company
Company Van Horn Automotive was created
Custom Key: location
Location Van Horn Ford of Oconomowoc already exists
Custom Key: manufacturer
Manufacturer Dell was created
Custom Key: status
Creating a new status
Status Ready to Deploy (deployed) was created
Custom Key: supplier
Custom Key: department
Custom Key: manager first name
Custom Key: manager last name
Custom Key: item name
Custom Key: notes
Custom Key: order number
Custom Key: purchase cost
Custom Key: purchase date
Custom Key: quantity
Custom Key: requestable
Custom Key: serial
Custom Key: checkout type
Custom Key: checkout location
Location Van Horn Ford of Oconomowoc already exists
Custom Key: asset tag
No Matching Asset, Creating a new one
Custom Key: image
Custom Key: warranty
Custom Key: model name
Custom Key: model number
No Matching Model, Creating a new one
Asset Model Optiplex 3050 with model number D11S was created
Asset VHOCOWSLS001 with serial number  was created

In Loggable.php line 44:

  [ErrorException]                      
  Trying to get property of non-object  

Exception trace:
 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at /media/www/var/www/snipeit/app/Models/Loggable.php:44
 App\Models\Asset->logCheckout() at /media/www/var/www/snipeit/app/Models/Asset.php:249
 App\Models\Asset->checkOut() at /media/www/var/www/snipeit/app/Importer/AssetImporter.php:117
 App\Importer\AssetImporter->createAssetIfNotExists() at /media/www/var/www/snipeit/app/Importer/AssetImporter.php:41
 App\Importer\AssetImporter->handle() at /media/www/var/www/snipeit/app/Importer/Importer.php:129
 App\Importer\Importer->App\Importer\{closure}() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:29
 Illuminate\Database\Connection->transaction() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:327
 Illuminate\Database\DatabaseManager->__call() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
 Illuminate\Support\Facades\Facade::__callStatic() at /media/www/var/www/snipeit/app/Importer/Importer.php:136
 App\Importer\Importer->import() at /media/www/var/www/snipeit/app/Console/Commands/ObjectImportCommand.php:83
 App\Console\Commands\ObjectImportCommand->fire() at n/a:n/a
 call_user_func_array() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
 Illuminate\Container\BoundMethod::callBoundMethod() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
 Illuminate\Container\BoundMethod::call() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/Container.php:539
 Illuminate\Container\Container->call() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php:182
 Illuminate\Console\Command->execute() at /media/www/var/www/snipeit/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php:167
 Illuminate\Console\Command->run() at /media/www/var/www/snipeit/vendor/symfony/console/Application.php:946
 Symfony\Component\Console\Application->doRunCommand() at /media/www/var/www/snipeit/vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at /media/www/var/www/snipeit/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /media/www/var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
 Illuminate\Foundation\Console\Kernel->handle() at /media/www/var/www/snipeit/artisan:35

Sample CSV

Company,Item Name,Asset Tag,Model Name,Model Number,Category,Manufacturer,Serial Number,Purchase Date,Purchase Cost,Location,Checkout Location,Checkout Type,Status,Warranty months,Full Name,Email
My Company,VHOCOWSLS001,VH000364,Optiplex 3050,D11S,Computer - Desktop,Dell Inc.,1AA11A1,,611.65,My Location,My Location,location,Ready to Deploy (deployed),12,,
My Company,VHPLDWPRT001,VH000577,Optiplex 3050,D11S,Computer - Desktop,Dell Inc.,2BB22B2,,645.29,My Location,My Location,user,Ready to Deploy (deployed),36,First Last,
stale[bot] commented 5 years ago

Is this still relevant? We haven't heard from anyone in a bit. If so, please comment with any updates or additional detail. This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Don't take it personally, we just need to keep a handle on things. Thank you for your contributions!

stale[bot] commented 5 years ago

This issue has been automatically closed because it has not had recent activity. If you believe this is still an issue, please confirm that this issue is still happening in the most recent version of Snipe-IT and reply to this thread to re-open it.

thanhpn7188 commented 5 years ago

same issues. I got an error page 404 when import data have data in "checkout type" is "location" ("user" is ok)

My version is snipeit is: 4.6.18 via wamp 32 bit