Snipe-it: 500 error when uploading user csv

Created on 8 Jul 2016  路  5Comments  路  Source: snipe/snipe-it

Expected Behavior (or desired behavior if a feature request)

When uploading a usr csv in the format given, I instantly receive a 500 error. I upload the file, click "this CSV has a header row" and straight to 500. There's nothing in the logs that point to an issue.


Actual Behavior


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 2.1.1
  • What OS and web server you're running Snipe-IT on 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc)
  • If you're getting an error in your browser, include that error
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error
  • 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.
  • Include any additional information you can find in app/storage/logs and your webserver's logs.
  • 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

Most helpful comment

"[2016-07-08 09:32:59] production.ERROR: ErrorException: Undefined offset: 7 in /var/www/snipeit/app/controllers/admin/UsersController.php:844"

It looks like the importer is expecting eight columns, but not finding them.

                            'first_name' => $row[0],
                            'last_name' => $row[1],
                            'username' => $row[2],
                            'email' => $row[3],
                            'password' => $pass, // Generated
                            'activated' => $activated, 
                            'location_id' => $user_location_id, // $row[4]
                            'phone' => $row[5],
                            'jobtitle' => $row[6],
                            'employee_num' => $row[7],

All 5 comments

Stack trace from /app/storage/logs
[2016-07-08 09:32:59] production.ERROR: ErrorException: Undefined offset: 7 in /var/www/snipeit/app/controllers/admin/UsersController.php:844
Stack trace:

0 /var/www/snipeit/app/controllers/admin/UsersController.php(844): Illuminate\Exception\Handler->handleError(8, 'Undefined offse...', '/var/www/snipei...', 844, Array)

1 [internal function]: Controllers\Admin\UsersController->Controllers\Admin{closure}(Array, 0, Object(CallbackFilterIterator))

2 /var/www/snipeit/vendor/league/csv/src/Reader.php(92): call_user_func(Object(Closure), Array, 0, Object(CallbackFilterIterator))

3 /var/www/snipeit/app/controllers/admin/UsersController.php(883): League\Csv\Reader->each(Object(Closure))

4 [internal function]: Controllers\Admin\UsersController->postImport()

5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)

6 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('postImport', Array)

7 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(Controllers\Admin\UsersController), Ob

ject(Illuminate\Routing\Route), 'postImport')

8 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(967): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Ht

tp\Request), 'Controllers\Adm...', 'postImport')

9 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}()

10 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Route.php(109): call_user_func_array(Object(Closure), Array)

11 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1033): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))

12 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1001): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

13 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

14 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))

15 /var/www/snipeit/vendor/barryvdh/laravel-debugbar/src/Middleware/Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)

16 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)

17 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)

18 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)

19 /var/www/snipeit/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)

20 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))

21 /var/www/snipeit/public/index.php(49): Illuminate\Foundation\Application->run()

22 {main} [] []

"[2016-07-08 09:32:59] production.ERROR: ErrorException: Undefined offset: 7 in /var/www/snipeit/app/controllers/admin/UsersController.php:844"

It looks like the importer is expecting eight columns, but not finding them.

                            'first_name' => $row[0],
                            'last_name' => $row[1],
                            'username' => $row[2],
                            'email' => $row[3],
                            'password' => $pass, // Generated
                            'activated' => $activated, 
                            'location_id' => $user_location_id, // $row[4]
                            'phone' => $row[5],
                            'jobtitle' => $row[6],
                            'employee_num' => $row[7],

Confirmed that there's 7 columns in my CSV: (data scrubbed for security purposes)
image

It looks like the 'phone' column is missing. The index is 0 based, so it should actually be eight columns (I mislead earlier).

First, Last, User, Email, Location, Phone, Job Title, Employee Num.

We both learned something today...BOOM! Worked great, thanks for the quick response!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anilp78 picture anilp78  路  4Comments

ericdude101 picture ericdude101  路  5Comments

ArchdukeNavaron picture ArchdukeNavaron  路  4Comments

laTruffe79 picture laTruffe79  路  4Comments

sopheaouk picture sopheaouk  路  3Comments