Skip to content

Entering an invalid cron expression fails silently #278

@jocmp

Description

@jocmp

Describe the bug
When entering a cron expression in the /admin/general settings, the "Save Changes" button will save invalid cron expressions resulting in an error when booting the background worker.

To Reproduce
Steps to reproduce the behavior:

  1. Go to /admin/general
  2. Enter an invalid cron expression into the "Speedtest schedule" text input such as * * * * * * * (too many fields)
  3. Save changes
  4. When restarting the server, an exception is thrown blocking server boot. The only remediation then is to clear the database entry
    [2022-12-29 19:45:44] production.ERROR: 6 is not a valid position {"exception":"[object] (InvalidArgumentException(code: 0): 6 is not a valid position at /var/www/html/vendor/dragonmantank/cron-expression/src/Cron/FieldFactory.php:48)

Expected behavior
Settings should not save invalid cron expressions.

Environment (please complete the following information):

  • OS: Ubuntu 22.04 via the Docker image
  • Architecture: amd64
  • Browser: chrome
  • Version: v0.9.1

Screenshots
Saving an invalid cron expression
Screenshot 2022-12-29 141847

Logs

 ./vendor/bin/sail php artisan queue:work

   INFO  Processing jobs from the [default] queue.

  2022-12-29 20:21:04 App\Jobs\SearchForSpeedtests ....................................................................................................................................................................................... RUNNING
  2022-12-29 20:21:04 App\Jobs\SearchForSpeedtests .................................................................................................................................................................................. 14.54ms FAIL
[2022-12-29 20:21:04] production.ERROR: 6 is not a valid position {"exception":"[object] (InvalidArgumentException(code: 0): 6 is not a valid position at /var/www/html/vendor/dragonmantank/cron-expression/src/Cron/FieldFactory.php:48)
[stacktrace]
#0 /var/www/html/vendor/dragonmantank/cron-expression/src/Cron/FieldFactory.php(30): Cron\\FieldFactory->instantiateField()
#1 /var/www/html/vendor/dragonmantank/cron-expression/src/Cron/CronExpression.php(230): Cron\\FieldFactory->getField()
#2 /var/www/html/vendor/dragonmantank/cron-expression/src/Cron/CronExpression.php(212): Cron\\CronExpression->setPart()
#3 /var/www/html/vendor/dragonmantank/cron-expression/src/Cron/CronExpression.php(187): Cron\\CronExpression->setExpression()
#4 /var/www/html/app/Jobs/SearchForSpeedtests.php(39): Cron\\CronExpression->__construct()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Jobs\\SearchForSpeedtests->handle()
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Container\\BoundMethod::call()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\\Container\\Container->call()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\\Pipeline\\Pipeline->then()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(124): Illuminate\\Bus\\Dispatcher->dispatchNow()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Queue\\CallQueuedHandler->Illuminate\\Queue\\{closure}()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(126): Illuminate\\Pipeline\\Pipeline->then()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\\Queue\\CallQueuedHandler->dispatchThroughMiddleware()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\\Queue\\CallQueuedHandler->call()
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(425): Illuminate\\Queue\\Jobs\\Job->fire()
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(375): Illuminate\\Queue\\Worker->process()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(173): Illuminate\\Queue\\Worker->runJob()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(146): Illuminate\\Queue\\Worker->daemon()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(130): Illuminate\\Queue\\Console\\WorkCommand->runWorker()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Container\\BoundMethod::call()
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\\Container\\Container->call()
#31 /var/www/html/vendor/symfony/console/Command/Command.php(312): Illuminate\\Console\\Command->execute()
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(152): Symfony\\Component\\Console\\Command\\Command->run()
#33 /var/www/html/vendor/symfony/console/Application.php(1022): Illuminate\\Console\\Command->run()
#34 /var/www/html/vendor/symfony/console/Application.php(314): Symfony\\Component\\Console\\Application->doRunCommand()
#35 /var/www/html/vendor/symfony/console/Application.php(168): Symfony\\Component\\Console\\Application->doRun()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\\Component\\Console\\Application->run()
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(155): Illuminate\\Console\\Application->run()
#38 /var/www/html/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#39 {main}
"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions