Skip to content

Undefined property: TaskFailed::$delay #55903

Closed
@Cluster2a

Description

@Cluster2a

Laravel Version

v12.14.1

PHP Version

8.4

Database Driver & Version

9.3.0

Description

Hey, I'm not quite sure if this is a bug or a mistake on my end.

I'm trying to notify a user that one of the tasks has failed:

$taskUser->notify(new TaskFailed(
    $taskSchedule->id,
    $taskRun->id,
    $taskSchedule->description,
    $taskRun->result
));

Here is the TaskFailed Notification class:

<?php

declare(strict_types=1);

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Carbon;

/**
 *
 */
class TaskFailed extends Notification implements ShouldQueue
{
    /**
     * The name of the connection the job should be sent to.
     *
     * @var string|null
     */
    public string|null $connection = 'redis';

    /**
     * The name of the queue the job should be sent to.
     *
     * @var string|null
     */
    public string|null $queue = 'notifications';

    /**
     * @var string
     */
    protected string $taskScheduleId;

    /**
     * @var string
     */
    protected string $taskScheduleRunId;

    /**
     * @var string
     */
    protected string $taskScheduleDescription;

    /**
     * @var string
     */
    protected string $taskScheduleRunResult;

    /**
     * Create a new notification instance.
     *
     * @param string $taskScheduleId
     * @param string $taskScheduleRunId
     * @param string $taskScheduleDescription
     * @param string $taskScheduleRunResult
     */
    public function __construct(
        string $taskScheduleId,
        string $taskScheduleRunId,
        string $taskScheduleDescription,
        string $taskScheduleRunResult,
    ) {
        $this->taskScheduleId = $taskScheduleId;
        $this->taskScheduleRunId = $taskScheduleRunId;
        $this->taskScheduleDescription = $taskScheduleDescription;
        $this->taskScheduleRunResult = $taskScheduleRunResult;
    }

    /**
     * Determine which connections should be used for each notification channel.
     *
     * @return array<string, string>
     */
    public function viaConnections(): array
    {
        return [
            'mail' => 'redis',
            'database' => 'sync',
        ];
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     *
     * @return array
     */
    public function via(mixed $notifiable): array
    {
        return [
            'mail',
            'database',
        ];
    }

    /**
     * @param mixed $notifiable
     *
     * @return array<string>
     */
    public function toArray(mixed $notifiable): array
    {
        return [
            'task_schedule_id' => $this->taskScheduleId,
            'task_schedule_runId' => $this->taskScheduleRunId,
            'task_schedule_description' => $this->taskScheduleDescription,
            'task_schedule_run_result' => $this->taskScheduleRunResult,
        ];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     *
     * @return MailMessage
     */
    public function toMail(mixed $notifiable): MailMessage
    {
        // mail sending logic...
    }
}

When the notification is being triggered, I’m getting the following error:
Undefined property: App\Freispace\TaskScheduler\Notifications\TaskFailed::$delay

Here is the sentry issue:

Image

I'm not sure what I'm missing - $delay is being accessed somewhere, but it's clearly not defined.

I checked the files in this repository, but couldn't find any recent changes related to the $delay property.

Steps To Reproduce

See issue description.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions