- Laravel Version: 5.5.0
- PHP Version: PHP 7.1.7-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jul 7 2017 09:41:45) ( NTS )
- Database Driver & Version: psql (PostgreSQL) 9.5.7
Description:
When using Laravel Passport, I'm getting the following error as a response when I use an oauth token:
Illuminate \ Database \ QueryException (22P02)
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "" (SQL: select * from "users" where "id" = limit 1)
I've also opened an issue on the passport repo but this seems like an issue that might be related to the framework itself, namely, the Postgres driver. Reading from other reports of this issue (see below), it seems like there is a parameter that doesn't get properly formatted, and thus not added to the query (where "id" = limit 1
doesn't include the actual id after =
). I think the framework somehow receives this value as a string, as opposed to an integer. Therefore, the query formatting fails. Does anyone have a solution for this, or at least an idea of where the bug may exist?
- https://github.com/laravel/framework/pull/18364
- https://github.com/laravel/passport/issues/54
- https://github.com/laravel/passport/issues/311
Steps To Reproduce:
- Configure a Postgres database driver
- Setup Passport by following the documentation on the Laravel website
- Generate an oauth token (I used Postman)
- Use this token in a request
Full stack trace:
[2017-09-05 15:27:04] local.ERROR: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "" (SQL: select * from "users" where "id" = limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \"\" (SQL: select * from \"users\" where \"id\" = limit 1) at /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 22P02): SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \"\" at /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php:330)
[stacktrace]
#0 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from \"...', Array, Object(Closure))
#1 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from \"...', Array, Object(Closure))
#2 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1705): Illuminate\\Database\\Connection->select('select * from \"...', Array, true)
#3 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1690): Illuminate\\Database\\Query\\Builder->runSelect()
#4 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(483): Illuminate\\Database\\Query\\Builder->get(Array)
#5 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(467): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#6 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(77): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#7 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php(51): Illuminate\\Database\\Eloquent\\Builder->first()
#8 /home/vagrant/Code/MyApp/vendor/laravel/passport/src/Guards/TokenGuard.php(116): Illuminate\\Auth\\EloquentUserProvider->retrieveById('')
#9 /home/vagrant/Code/MyApp/vendor/laravel/passport/src/Guards/TokenGuard.php(90): Laravel\\Passport\\Guards\\TokenGuard->authenticateViaBearerToken(Object(Illuminate\\Http\\Request))
#10 /home/vagrant/Code/MyApp/vendor/laravel/passport/src/PassportServiceProvider.php(267): Laravel\\Passport\\Guards\\TokenGuard->user(Object(Illuminate\\Http\\Request))
#11 [internal function]: Laravel\\Passport\\PassportServiceProvider->Laravel\\Passport\\{closure}(Object(Illuminate\\Http\\Request), NULL)
#12 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php(58): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request), NULL)
#13 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php(50): Illuminate\\Auth\\RequestGuard->user()
#14 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(61): Illuminate\\Auth\\RequestGuard->check()
#15 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(41): Illuminate\\Auth\\Middleware\\Authenticate->authenticate(Array)
#16 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure), 'api')
#17 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#19 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#20 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Router.php(571): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#21 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Router.php(549): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#22 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#23 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#38 /home/vagrant/Code/MyApp/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#39 /home/vagrant/Code/MyApp/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#40 {main}
"}