laravel/framework · error · RuntimeException
Invoke an attribute method such as Schedule::daily() before
Error message
Invoke an attribute method such as Schedule::daily() before defining a schedule group.
What it means
Thrown by Schedule::group() (src/Illuminate/Console/Scheduling/Schedule.php:334) when $this->attributes is null — i.e. group() was called before any attribute method (daily(), hourly(), runInBackground(), etc.) populated pending attributes. Groups apply shared attributes to every event inside, so they must be set first.
Source
Thrown at src/Illuminate/Console/Scheduling/Schedule.php:334
$this->events[] = $event = new Event($this->eventMutex, $command, $this->timezone);
$this->mergePendingAttributes($event);
return $event;
}
/**
* Create new schedule group.
*
* @param \Closure $events
* @return void
*
* @throws \RuntimeException
*/
public function group(Closure $events)
{
if ($this->attributes === null) {
throw new RuntimeException('Invoke an attribute method such as Schedule::daily() before defining a schedule group.');
}
$this->groupStack[] = $this->attributes;
$this->attributes = null;
$events($this);
array_pop($this->groupStack);
}
/**
* Merge the current group attributes with the given event.
*
* @param \Illuminate\Console\Scheduling\Event $event
* @return void
*/
protected function mergePendingAttributes(Event $event)
{View on GitHub (pinned to bd6b5437e6)
Solutions
- Chain an attribute method before group(): $schedule->daily()->group(fn ($s) => ...).
- Move shared constraints (timezone, environments) inside the group via attribute calls on $s.
- If no shared attributes are needed, don't use group() — register events directly.
Example fix
// before
$schedule->group(function ($schedule) {
$schedule->call(fn () => x())->daily();
$schedule->command('reports:send')->daily();
});
// after
$schedule->daily()->group(function ($schedule) {
$schedule->call(fn () => x());
$schedule->command('reports:send');
}); Defensive patterns
Strategy: validation
Validate before calling
// group() requires attributes set first; ensure an attribute method runs first $schedule->daily()->group(fn ($s) => /* events */);
Type guard
// internal-only: attributes populated by an attribute call // users guard by always chaining an attribute before group()
Try / catch
try {
$schedule->group($closure);
} catch (\RuntimeException $e) {
$schedule->daily()->group($closure); // retry with attribute
} Prevention
- Always chain a frequency/attribute method before group().
- Skip group() when no shared attributes are needed.
- Add a lint rule banning bare group() calls.
When it happens
Trigger: Writing $schedule->group(function ($schedule) { $schedule->call(...); }); with no prior attribute call like $schedule->daily()->group(...).
Common situations: Adopting the fluent Schedule builder API and forgetting the attribute chain; refactoring that drops the attribute call before group.
Related errors
- Method %s::%s does not exist.
- Invalid scheduled callback event. Must be a string or callab
- Scheduled closures can not be run in the background.
- A scheduled event name is required to prevent overlapping. U
- A scheduled event name is required to only run on one server
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/089fc8dec2e49418.json.
Report an issue: GitHub.