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

Sentry queue tracing is possibly passing null to a Symfony component during Artisan::queue() #588

Closed
localpath opened this issue Oct 12, 2022 · 6 comments · Fixed by #589
Assignees

Comments

@localpath
Copy link

localpath commented Oct 12, 2022

Environment

--Staging--
Ubuntu 20.04

laravel/framework - 9.34.0
sentry/sentry-laravel - 2.14.1

--Dev--
Debian GNU/Linux 10 (buster)

laravel/framework - 9.34.0
sentry/sentry-laravel - 2.14.1

Steps to Reproduce

  1. Upgraded application to Laravel 9 w/ latest Sentry
  2. Tested controller method that calls a console command using Artisan::queue()
  3. Job went to the queue and worked as normal
  4. Sentry is not enabled locally ie DSN = null
  5. Promoted code to staging where sentry is enabled
  6. Used controller in same manner in staging, got exception
  7. Enabled sentry locally, can generate error locally if DSN != null ie sentry enabled

Expected Result

Sentry would not cause the artisan queue command handler to fail.

Actual Result

--Staging--
https://sentry.io/share/issue/034cdb67d179495d85e53621563566e8/

--Local--
https://sentry.io/share/issue/034cdb67d179495d85e53621563566e8/

TypeError: Symfony\Component\Console\Input\Input::escapeToken(): Argument #1 ($token) must be of type string, null given, called in /var/www/giving/vendor/symfony/console/Input/ArrayInput.php on line 118

image

TypeError: Symfony\Component\Console\Input\Input::escapeToken(): Argument #1 ($token) must be of type string, null given, called in /var/www/giving/vendor/symfony/console/Input/ArrayInput.php on line 118
#44 /vendor/symfony/console/Input/Input.php(191): Symfony\Component\Console\Input\Input::escapeToken
#43 /vendor/symfony/console/Input/ArrayInput.php(118): Symfony\Component\Console\Input\ArrayInput::__toString
#42 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/EventHandler.php(561): Sentry\Laravel\EventHandler::commandStartingHandler
#41 [internal](0): call_user_func_array
#40 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/EventHandler.php(271): Sentry\Laravel\EventHandler::__call
#39 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(421): Illuminate\Events\Dispatcher::Illuminate\Events\{closure}
#38 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher::dispatch
#37 /vendor/laravel/framework/src/Illuminate/Console/Application.php(98): Illuminate\Console\Application::run
#36 /vendor/laravel/framework/src/Illuminate/Console/Application.php(194): Illuminate\Console\Application::call
#35 /vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(328): Illuminate\Foundation\Console\Kernel::call
#34 /vendor/laravel/framework/src/Illuminate/Foundation/Console/QueuedCommand.php(40): Illuminate\Foundation\Console\QueuedCommand::handle
#33 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
#32 /vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\Util::unwrapIfClosure
#31 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\BoundMethod::callBoundMethod
#30 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::call
#29 /vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Container\Container::call
#28 /vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\Bus\Dispatcher::Illuminate\Bus\{closure}
#27 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#26 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline::then
#25 /vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Bus\Dispatcher::dispatchNow
#24 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(124): Illuminate\Queue\CallQueuedHandler::Illuminate\Queue\{closure}
#23 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#22 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline::then
#21 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(126): Illuminate\Queue\CallQueuedHandler::dispatchThroughMiddleware
#20 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler::call
#19 /vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\Jobs\Job::fire
#18 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(425): Illuminate\Queue\Worker::process
#17 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(375): Illuminate\Queue\Worker::runJob
#16 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(173): Illuminate\Queue\Worker::daemon
#15 /vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(150): Illuminate\Queue\Console\WorkCommand::runWorker
#14 /vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(134): Illuminate\Queue\Console\WorkCommand::handle
#13 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
#12 /vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\Util::unwrapIfClosure
#11 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\BoundMethod::callBoundMethod
#10 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::call
#9 /vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Container\Container::call
#8 /vendor/laravel/framework/src/Illuminate/Console/Command.php(144): Illuminate\Console\Command::execute
#7 /vendor/symfony/console/Command/Command.php(291): Symfony\Component\Console\Command\Command::run
#6 /vendor/laravel/framework/src/Illuminate/Console/Command.php(126): Illuminate\Console\Command::run
#5 /vendor/symfony/console/Application.php(1002): Symfony\Component\Console\Application::doRunCommand
#4 /vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application::doRun
#3 /vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application::run
#2 /vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Illuminate\Console\Application::run
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(151): Illuminate\Foundation\Console\Kernel::handle
#0 /artisan(35): null
@stayallive
Copy link
Collaborator

Can you also share how you are calling Artisan::queue, are you passing in any arguments for example?

We shall try to reproduce but it seems like we are trying to extract some data from the command that is running that is invalid or in an incorrect state causing this issue.

To be clear, we shouldn't cause issues of course, but we are not explicitly setting or mutating Artisan arguments so I'm a little puzzled 🤨

(also, already, thanks for your very detailed report)

@stayallive
Copy link
Collaborator

So doing this results in the same error: Artisan::call('command:name', ['arg' => null]);.

I think you are passing null as one of the arguments which Symfony is not liking very much when we are trying to convert the input to a string.

Let's fix that!

@stayallive
Copy link
Collaborator

So I think I got it, #589.

You can try it out by replacing "sentry/sentry-laravel": "^2.14" with "sentry/sentry-laravel": "dev-fix-command-input-handling" temporarily.

Would be greatly appreciated if you can test the fix on your end too!

@localpath
Copy link
Author

@stayallive Hello. Yes thanx for quick reply. We upgraded from Laravel 6 to 9 and allowed passing like this

Artisan::call('command:name', ['arg' => ?string])

stricter type hinting is what I suspected. Thanx. I will reproduce to check but that sounds correct.

@localpath
Copy link
Author

@stayallive Yes I can confirm that passing a null input for Artisan::queue() does not cause an exception on your patch version

@stayallive
Copy link
Collaborator

Perfect, we'll release a bug fix first thing in the European morning. Thanks for reporting and validating the fix 🙌

@cleptric cleptric self-assigned this Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants