{"id":"fb1b7ffcbf0bbda2","repo":"laravel/framework","slug":"the-seconds-seconds-must-be-greater-than-zero","errorCode":null,"errorMessage":"The seconds [$seconds] must be greater than zero.","messagePattern":"The seconds \\[\\$seconds\\] must be greater than zero\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Console/Scheduling/ManagesFrequencies.php","lineNumber":165,"sourceCode":"     * @return $this\n     */\n    public function everyThirtySeconds()\n    {\n        return $this->repeatEvery(30);\n    }\n\n    /**\n     * Schedule the event to run multiple times per minute.\n     *\n     * @param  int<1, 59>  $seconds\n     * @return $this\n     *\n     * @throws \\InvalidArgumentException\n     */\n    protected function repeatEvery($seconds)\n    {\n        if ($seconds <= 0) {\n            throw new InvalidArgumentException(\"The seconds [$seconds] must be greater than zero.\");\n        }\n\n        if (60 % $seconds !== 0) {\n            throw new InvalidArgumentException(\"The seconds [$seconds] are not evenly divisible by 60.\");\n        }\n\n        $this->repeatSeconds = $seconds;\n\n        return $this->everyMinute();\n    }\n\n    /**\n     * Schedule the event to run every minute.\n     *\n     * @return $this\n     */\n    public function everyMinute()\n    {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Console/Scheduling/ManagesFrequencies.php#L147-L183","documentation":"Thrown by ManagesFrequencies::repeatEvery() (src/Illuminate/Console/Scheduling/ManagesFrequencies.php:165) when $seconds <= 0. The sub-minute repeat feature (everySecond/everyFiveSeconds/...) divides the minute evenly and requires a positive interval.","triggerScenarios":"Calling repeatEvery(0), repeatEvery(-5), or the public helpers everySecond() / everyFiveSeconds() with a value computed to <= 0. Also possible if a user-facing input flows into repeatEvery without sanitization.","commonSituations":"Dynamic code computing seconds from user input and passing 0; misconfigured tests; passing null which coerces to 0.","solutions":["Ensure seconds is a positive integer between 1 and 59.","Guard user-supplied values: max(1, (int) $input).","Use the named helpers (everySecond/everyFiveSeconds/...) for fixed intervals.","If 0 means 'disabled', branch before calling the scheduler."],"exampleFix":"// before\n$event->repeatEvery($userSeconds);  // $userSeconds = 0\n\n// after\n$seconds = max(1, (int) $userSeconds);\nif ($seconds > 0) {\n    $event->repeatEvery($seconds);\n}","handlingStrategy":"validation","validationCode":"$seconds = (int) $input;\nif ($seconds <= 0) {\n    // skip scheduling or clamp to a positive value\n}","typeGuard":"function isValidSeconds(int $s): bool\n{\n    return $s > 0 && $s < 60;\n}","tryCatchPattern":"try {\n    $event->repeatEvery($seconds);\n} catch (\\InvalidArgumentException $e) {\n    // default to a known-good interval\n    $event->everyMinute();\n}","preventionTips":["Sanitize user input before computing sub-minute intervals.","Prefer framework helpers (everySecond/everyFiveSeconds).","Treat 0 as 'disabled' and branch before scheduling."],"tags":["scheduling","console","validation","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}