From 15bb3559d3c2a61c17d249edcca73dc1ed14e179 Mon Sep 17 00:00:00 2001 From: Justin Shin Date: Wed, 11 Feb 2026 13:14:21 -0500 Subject: [PATCH] Add defensive check to `GetRecurringJobIds` to prevent null reference exception. --- .../Services/HangfireWorkflowScheduler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/scheduling/Elsa.Scheduling.Hangfire/Services/HangfireWorkflowScheduler.cs b/src/modules/scheduling/Elsa.Scheduling.Hangfire/Services/HangfireWorkflowScheduler.cs index 3b389e68..bff4c4e9 100644 --- a/src/modules/scheduling/Elsa.Scheduling.Hangfire/Services/HangfireWorkflowScheduler.cs +++ b/src/modules/scheduling/Elsa.Scheduling.Hangfire/Services/HangfireWorkflowScheduler.cs @@ -97,7 +97,9 @@ private IEnumerable GetQueuedJobIds(string taskName) private IEnumerable GetRecurringJobIds(string taskName) { using var connection = jobStorage.GetConnection(); - var jobs = connection.GetRecurringJobs().Where(x => x.Job.Type == typeof(TJob) && (string)x.Job.Args[0] == taskName); + var jobs = connection.GetRecurringJobs() + .Where(x => x.Job is { Args.Count: > 0 } && x.Job.Type == typeof(TJob) && (string)x.Job.Args[0] == taskName); + return jobs.Select(x => x.Id).Distinct().ToList(); } } \ No newline at end of file