Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whoops! When creating user in pre-flight #6710

Closed
alaneil opened this issue Feb 13, 2019 · 17 comments
Closed

Whoops! When creating user in pre-flight #6710

alaneil opened this issue Feb 13, 2019 · 17 comments

Comments

@alaneil
Copy link

alaneil commented Feb 13, 2019

Describe the bug
I am unable to create my first user account in the pre-flight, or rather it is being created because I can't register with the same email, but I only receive the Whoops! error and cannot proceed.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'localhost'
  2. Click on 'next' after entering user details
  3. See error

Expected behavior
The user is created (im assuming, the email is considered in-use after this), but I am given an error and the pre-flight does not progress beyond this.

Screenshots
If applicable, add screenshots to help explain your problem.

Server (please complete the following information):

  • Snipe-IT Version 4.6.3
  • OS: [e.g. Ubuntu, CentOS] Ubuntu 18.04
  • Web Server: [e.g. Apache, IIS] Apache
  • PHP Version 5.6.4

Desktop (please complete the following information):

  • OS: [e.g. iOS] Win10 Pro build 1809
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] 71

Error Messages

(3/3) QueryExceptionSQLSTATE[23000]: Integrity constraint violation: 1048 Column 'auto_increment_prefix' cannot be null (SQL: insert into settings (full_multiple_companies_support, site_name, alert_email, alerts_enabled, pwd_secure_min, brand, locale, default_currency, user_id, email_domain, email_format, next_auto_tag_base, auto_increment_assets, auto_increment_prefix, updated_at, created_at) values (0, Test Asset Management, test.inventory@gmail.com, 1, 10, 1, en, USD, 1, gmail.com, filastname, 1, 0, , 2019-02-13 20:39:24, 2019-02-13 20:39:24))

in Connection.php line 647
at Connection->runQueryCallback('insert into settings (full_multiple_companies_support, site_name, alert_email, alerts_enabled, pwd_secure_min, brand, locale, default_currency, user_id, email_domain, email_format, next_auto_tag_base, auto_increment_assets, auto_increment_prefix, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(0, 'Test Asset Management', 'test.inventory@gmail.com', 1, 10, 1, 'en', 'USD', 1, 'gmail.com', 'filastname', 1, 0, null, '2019-02-13 20:39:24', '2019-02-13 20:39:24'), object(Closure))in Connection.php line 607
at Connection->run('insert into settings (full_multiple_companies_support, site_name, alert_email, alerts_enabled, pwd_secure_min, brand, locale, default_currency, user_id, email_domain, email_format, next_auto_tag_base, auto_increment_assets, auto_increment_prefix, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(0, 'Test Asset Management', 'test.inventory@gmail.com', 1, 10, 1, 'en', 'USD', 1, 'gmail.com', 'filastname', 1, 0, null, '2019-02-13 20:39:24', '2019-02-13 20:39:24'), object(Closure))in Connection.php line 450
at Connection->statement('insert into settings (full_multiple_companies_support, site_name, alert_email, alerts_enabled, pwd_secure_min, brand, locale, default_currency, user_id, email_domain, email_format, next_auto_tag_base, auto_increment_assets, auto_increment_prefix, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(0, 'Test Asset Management', 'test.inventory@gmail.com', 1, 10, 1, 'en', 'USD', 1, 'gmail.com', 'filastname', 1, 0, null, '2019-02-13 20:39:24', '2019-02-13 20:39:24'))in Connection.php line 404
at Connection->insert('insert into settings (full_multiple_companies_support, site_name, alert_email, alerts_enabled, pwd_secure_min, brand, locale, default_currency, user_id, email_domain, email_format, next_auto_tag_base, auto_increment_assets, auto_increment_prefix, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(0, 'Test Asset Management', 'test.inventory@gmail.com', 1, 10, 1, 'en', 'USD', 1, 'gmail.com', 'filastname', 1, 0, null, '2019-02-13 20:39:24', '2019-02-13 20:39:24'))in Processor.php line 32
at Processor->processInsertGetId(object(Builder), 'insert into settings (full_multiple_companies_support, site_name, alert_email, alerts_enabled, pwd_secure_min, brand, locale, default_currency, user_id, email_domain, email_format, next_auto_tag_base, auto_increment_assets, auto_increment_prefix, updated_at, created_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(0, 'Test Asset Management', 'test.inventory@gmail.com', 1, 10, 1, 'en', 'USD', 1, 'gmail.com', 'filastname', 1, 0, null, '2019-02-13 20:39:24', '2019-02-13 20:39:24'), 'id')in Builder.php line 2133
at Builder->insertGetId(array('full_multiple_companies_support' => 0, 'site_name' => 'Test Asset Management', 'alert_email' => 'test.inventory@gmail.com', 'alerts_enabled' => 1, 'pwd_secure_min' => 10, 'brand' => 1, 'locale' => 'en', 'default_currency' => 'USD', 'user_id' => 1, 'email_domain' => 'gmail.com', 'email_format' => 'filastname', 'next_auto_tag_base' => 1, 'auto_increment_assets' => 0, 'auto_increment_prefix' => null, 'updated_at' => '2019-02-13 20:39:24', 'created_at' => '2019-02-13 20:39:24'), 'id')in Builder.php line 1251
at Builder->__call('insertGetId', array(array('full_multiple_companies_support' => 0, 'site_name' => 'Test Asset Management', 'alert_email' => 'test.inventory@gmail.com', 'alerts_enabled' => 1, 'pwd_secure_min' => 10, 'brand' => 1, 'locale' => 'en', 'default_currency' => 'USD', 'user_id' => 1, 'email_domain' => 'gmail.com', 'email_format' => 'filastname', 'next_auto_tag_base' => 1, 'auto_increment_assets' => 0, 'auto_increment_prefix' => null, 'updated_at' => '2019-02-13 20:39:24', 'created_at' => '2019-02-13 20:39:24'), 'id'))in Model.php line 688
at Builder->insertGetId(array('full_multiple_companies_support' => 0, 'site_name' => 'Test Asset Management', 'alert_email' => 'test.inventory@gmail.com', 'alerts_enabled' => 1, 'pwd_secure_min' => 10, 'brand' => 1, 'locale' => 'en', 'default_currency' => 'USD', 'user_id' => 1, 'email_domain' => 'gmail.com', 'email_format' => 'filastname', 'next_auto_tag_base' => 1, 'auto_increment_assets' => 0, 'auto_increment_prefix' => null, 'updated_at' => '2019-02-13 20:39:24', 'created_at' => '2019-02-13 20:39:24'), 'id')in Model.php line 688
at Model->insertAndSetId(object(Builder), array('full_multiple_companies_support' => 0, 'site_name' => 'Test Asset Management', 'alert_email' => 'test.inventory@gmail.com', 'alerts_enabled' => 1, 'pwd_secure_min' => 10, 'brand' => 1, 'locale' => 'en', 'default_currency' => 'USD', 'user_id' => 1, 'email_domain' => 'gmail.com', 'email_format' => 'filastname', 'next_auto_tag_base' => 1, 'auto_increment_assets' => 0, 'auto_increment_prefix' => null, 'updated_at' => '2019-02-13 20:39:24', 'created_at' => '2019-02-13 20:39:24'))in Model.php line 653
at Model->performInsert(object(Builder))in Model.php line 522
at Model->save()in SettingsController.php line 187
at SettingsController->postSaveFirstAdmin(object(SetupUserRequest))
at call_user_func_array(array(object(SettingsController), 'postSaveFirstAdmin'), array(object(SetupUserRequest)))in Controller.php line 55
at Controller->callAction('postSaveFirstAdmin', array(object(SetupUserRequest)))in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(SettingsController), 'postSaveFirstAdmin')in Route.php line 204
at Route->runController()in Route.php line 160
at Route->run()in Router.php line 572
at Router->Illuminate\Routing{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing{closure}(object(Request))in CreateFreshApiToken.php line 49
at CreateFreshApiToken->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in CheckForTwoFactor.php line 49
at CheckForTwoFactor->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in CheckLocale.php line 42
at CheckLocale->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in Pipeline.php line 102
at Pipeline->then(object(Closure))in Router.php line 574
at Router->runRouteWithinStack(object(Route), object(Request))in Router.php line 533
at Router->dispatchToRoute(object(Request))in Router.php line 511
at Router->dispatch(object(Request))in Kernel.php line 176
at Kernel->Illuminate\Foundation\Http{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing{closure}(object(Request))in Debugbar.php line 51
at Debugbar->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in CheckForDebug.php line 25
at CheckForDebug->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in CheckForSetup.php line 35
at CheckForSetup->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in TrustProxies.php line 56
at TrustProxies->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in NosniffGuard.php line 17
at NosniffGuard->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in ContentSecurityPolicyHeader.php line 18
at ContentSecurityPolicyHeader->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in ReferrerPolicyHeader.php line 17
at ReferrerPolicyHeader->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in XssProtectHeader.php line 18
at XssProtectHeader->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in FrameGuard.php line 17
at FrameGuard->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure))in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing{closure}(object(Request))in Pipeline.php line 102
at Pipeline->then(object(Closure))in Kernel.php line 151
at Kernel->sendRequestThroughRouter(object(Request))in Kernel.php line 116
at Kernel->handle(object(Request))in index.php line 59

Additional context

  • Is this a fresh install or an upgrade? Fresh install
  • What OS and web server you're running Snipe-IT on: Ubuntu 18.04 / Apache
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) Git
  • Include what you've done so far in the installation, and if you got any error messages along the way: I followed the instructions in TechCoreDuo's youtube video on Ubuntu SnipeIT installation.
  • Indicate whether or not you've manually edited any data directly in the database: I have not.

I was wondering if possibly this error was from installing composer with the sudo command, or possibly PHP, but I really have no experience with Linux in the first place so it could be anything. I really appreciate any advice.

@alaneil alaneil changed the title Whoops! When creating user in ore-flight Whoops! When creating user in pre-flight Feb 13, 2019
@metrodleal
Copy link

Monitoring this issue as I'm getting the same error on a bone-stock CentOS7 install of SnipeIT using the install.sh script: Integrity constraint violation: 1048 Column 'auto_increment_prefix' cannot be null

@JoshCBS
Copy link

JoshCBS commented Feb 14, 2019

Same issue.

Running on a fresh install of Ubuntu 18.04.1 LTS.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'auto_increment_prefix' cannot be null

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

I kinda don't understand why this would just be coming up. That field was created over a year ago. Are you all maybe using the same version of MySQL, maybe a newer one?

(In the future, instead of just the "Me too"s, it would be helpful if you tell us versions of Snipe-IT, PHP, MySQL, etc. )

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

In app/Http/Controllers/SettingsController.php in the postSaveFirstAdmin() method, change

$settings->auto_increment_prefix = $request->input('auto_increment_prefix');

to

$settings->auto_increment_prefix = $request->input('auto_increment_prefix', '');

and let me know if that helps.

@Tester2009
Copy link

I faced the same issue when to install by using following command

wget https://raw.githubusercontent.com/snipe/snipe-it/master/install.sh
chmod 744 install.sh
./install.sh

I followed what you instruct to do, but seems failed also.

image

Im using PHP 7.2.15 and mysql 15.1 distrib, Ubuntu 18.04.2 LTS

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

@Tester2009 without more information, I have no way of knowing whether your issue is related or not. It doesn't sound like it is.

@metrodleal
Copy link

metrodleal commented Feb 14, 2019

@snipe, firstly thank you for your quick response. I really appreciate all the work you've put into this project and I'm looking forward to getting an instance running for my team.

I'm using CentOS within a VM using vSphere server, so it's easy for me to use snapshots to try different fixes. I'm running from a snapshot of after installation with install.sh but before the initial pre-flight (which passes all checks).

I tried your suggestion above of modifying postSaveFirstAdmin() and still got the same error I posted above, which always shows up as 3 QueryExceptions.

I have a hunch it's something to do with MariaDB/MySQL, as the installer may be pulling a more recent version for some of us than Snipe-IT has been tested with. I'm quite happy to revert my MariaDB/MySQL to an earlier version if you can recommend a version you know works - can you let me know which versions the install.sh script was designed to pull?

CentOS: 7.6.1810
Snipe-IT: 4.6.3
MySQL: 15.1 Distrib 5.5.60-MariaDB
PHP: 7.1.26 // Zend: 3.1.0
httpd: 2.4.6-88

Steps to reproduce:
Spin up CentOS 7 VM
sudo yum update -y, reboot
Install Snipe-IT using install.sh
Open Firefox
Save first user in pre-flight

Again, thanks for your help!

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

@metrodleal okay, let's try this:

In database/migrations/2014_11_20_224421_add_prefix_to_settings.php

Change:

$table->string('auto_increment_prefix')->default(0);

to:

$table->string('auto_increment_prefix')->nullable()->default(NULL);

You'll have to start over, as the tables will need to be recreated with that modifier.

Alternatively, if you can access the database directly, try running:

ALTER TABLE settings MODIFY auto_increment_prefix varchar(191) null; and then retrying to create your admin user.

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

I'm quite happy to revert my MariaDB/MySQL to an earlier version if you can recommend a version you know works

I'd rather fix this in the code, as we have lots of users who aren't as comfortable downgrading databases, etc. - but I suspect you're right. My guess would be null value treatment changed in a Maria/MySQL version somewhere. Otherwise we'd have been seeing this since... checks migration date.... 2014.

snipe added a commit that referenced this issue Feb 14, 2019
…le (#6716)

* Possible fix for #6710 - explicitly make auto_increment_prefix nullable

* Added migration to make auto_increment_prefix explicitly nullable
@snipe
Copy link
Owner

snipe commented Feb 14, 2019

I just merged that PR that includes another migration to set that field to explicitly nullable. Try pulling it down from master and running migrations, then trying your pre-flight again.

@metrodleal
Copy link

Up and running! Thanks @snipe, you rock!

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

Awesome! Sorry for the hassle.

3ghozea

Did you do it via master (the new migration?) Just trying to confirm which thing worked :D

If via master/new migration, I'll release a new version shortly with that fix in it, as not everyone likes pulling from master.

@metrodleal
Copy link

Yep - I was midway through applying your second tweak when I saw your comment, so I just scrubbed the VM and did a new install from master.

No hassle at at all - I'm both impressed at your quick skillz and glad to have helped in nailing down the fix for future releases!

@snipe
Copy link
Owner

snipe commented Feb 14, 2019

glad to have helped in nailing down the fix for future releases!

It's much appreciated. We try really hard to keep compatibility working across tons of different scenarios (distros, database versions, etc - some people actually run Snipe-IT on a raspberry pi!), but it can be a moving target, and sometimes we miss something. I'm always glad to bang out a fix sooner rather than later to prevent a buttload of new issues and tons of frustration on the user's side.

@JoshCBS
Copy link

JoshCBS commented Feb 14, 2019

Can confirm that by using
ALTER TABLE settings MODIFY auto_increment_prefix varchar(191) null;
the issue was resolved for me. Ubuntu 18.04, GIT installation.

Thank you for your prompt and accurate assistance!

@alaneil
Copy link
Author

alaneil commented Feb 15, 2019

I'm looking forward to trying this at the office in the morning! Thank you so much for the extremely prompt reply and (hopeful) fix! I hope you don't mind me leaving this open until I'm able to test it myself, though I fully suspect I won't be having any problems.

@alaneil
Copy link
Author

alaneil commented Feb 15, 2019

Confirmed that the issue is fixed on our end as well! Once again, thank you so much for providing an incredible response time for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants