coollabsio/coolify · error · Exception

Invalid Cron / Human expression.

Error message

Invalid Cron / Human expression.

What it means

syncData(toModel: true) on the scheduled-task screen validates the frequency field with validate_cron_expression(), which wraps cron-parser's CronExpression::isValid() plus a lookup in the VALID_CRON_STRINGS human-friendly map (keys like every_minute). When validation fails the field is reverted to the task's stored frequency and the save is aborted with this exception.

Source

Thrown at app/Livewire/Project/Shared/ScheduledTask/Show.php:95

                'application_uuid' => $application_uuid,
                'service_uuid' => $service_uuid,
            ];

            $this->task = $this->resource->scheduled_tasks()->where('uuid', $task_uuid)->firstOrFail();
            $this->syncData();
        } catch (\Exception $e) {
            return handleError($e);
        }
    }

    public function syncData(bool $toModel = false)
    {
        if ($toModel) {
            $this->validate();
            $isValid = validate_cron_expression($this->frequency);
            if (! $isValid) {
                $this->frequency = $this->task->frequency;
                throw new \Exception('Invalid Cron / Human expression.');
            }
            $this->task->enabled = $this->isEnabled;
            $this->task->name = str($this->name)->trim()->value();
            $this->task->command = str($this->command)->trim()->value();
            $this->task->frequency = str($this->frequency)->trim()->value();
            $this->task->container = str($this->container)->trim()->value();
            $this->task->timeout = (int) $this->timeout;
            $this->task->save();
        } else {
            $this->isEnabled = $this->task->enabled;
            $this->name = $this->task->name;
            $this->command = $this->task->command;
            $this->frequency = $this->task->frequency;
            $this->container = $this->task->container;
            $this->timeout = $this->task->timeout ?? 300;
        }
    }

View on GitHub (pinned to 70b9acc424)

Solutions

  1. Use a standard 5-field cron expression: minute hour day-of-month month day-of-week, e.g. '*/5 * * * *'
  2. Or use one of Coolify's exact human strings such as every_minute (match the preset keys, no free-form English)
  3. Re-copy the value from the UI frequency picker instead of typing manually
  4. Sanity-check the expression with the same library: php artisan tinker --execute 'var_dump(validate_cron_expression("*/5 * * * *"));'

Example fix

// before
$this->frequency = 'every 5 minutes';

// after
$this->frequency = '*/5 * * * *'; // or an exact preset key like 'every_minute'
Defensive patterns

Strategy: validation

Validate before calling

if (! validate_cron_expression($frequency)) {
    return 'Invalid Cron / Human expression.'; // fix input before syncData(true)
}

Try / catch

Wrap syncData(true) in try { } catch (\Exception $e) { return handleError($e, $this); } as the component does; re-display the reverted (stored) frequency so the user sees the canonical value.

Prevention

When it happens

Trigger: Entering a malformed 5-field cron (e.g. '*/2 * * *' with only 4 fields), a 6-field seconds-based cron, a human string not in VALID_CRON_STRINGS (e.g. 'every 5 minutes' or 'every minut'), or a copy-pasted crontab line that includes the username column.

Common situations: Copying crontab entries from tutorials (which often include the user field); using Jenkins/Quartz-style 6-field expressions; typos in the human-readable presets; trailing whitespace or smart quotes from pasting.

Related errors


AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17). Data as JSON: /api/errors/a798b812d7dde934. Report an issue: GitHub.