{"record":{"id":"170d3856e5338bcc","repo":"HangfireIO/Hangfire","slug":"the-job-field-has-a-null-or-empty-value","errorCode":null,"errorMessage":"The 'Job' field has a null or empty value","messagePattern":"The 'Job' field has a null or empty value","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/RecurringJobExtensions.cs","lineNumber":112,"sourceCode":"        }\n\n        public static BackgroundJob TriggerRecurringJob(\n            [NotNull] this IBackgroundJobFactory factory,\n            [NotNull] JobStorage storage,\n            [NotNull] IStorageConnection connection,\n            [NotNull] IProfiler profiler,\n            [NotNull] RecurringJobEntity recurringJob,\n            DateTime now)\n        {\n            if (factory == null) throw new ArgumentNullException(nameof(factory));\n            if (storage == null) throw new ArgumentNullException(nameof(storage));\n            if (connection == null) throw new ArgumentNullException(nameof(connection));\n            if (profiler == null) throw new ArgumentNullException(nameof(profiler));\n            if (recurringJob == null) throw new ArgumentNullException(nameof(recurringJob));\n\n            if (recurringJob.Job == null)\n            {\n                throw new InvalidOperationException(\"The 'Job' field has a null or empty value\");\n            }\n\n            var job = InvocationData.DeserializePayload(recurringJob.Job).DeserializeJob();\n\n            var context = new CreateContext(storage, connection, job, null, null, profiler, null);\n            context.Parameters[\"RecurringJobId\"] = recurringJob.RecurringJobId;\n            context.Parameters[\"Time\"] = JobHelper.ToTimestamp(now);\n\n            var backgroundJob = factory.Create(context);\n\n            recurringJob.LastExecution = now;\n            recurringJob.LastJobId = backgroundJob?.Id;\n\n            return backgroundJob;\n        }\n\n        public static void EnqueueBackgroundJob(\n            [NotNull] this IStateMachine stateMachine,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/RecurringJobExtensions.cs#L94-L130","documentation":"Thrown by TriggerRecurringJob when the RecurringJobEntity.Job payload is null, meaning the recurring job entry in storage has no serialized job definition. Hangfire cannot create a background job without a target method, so triggering is impossible. This usually means the storage entry is incomplete or corrupt.","triggerScenarios":"Calling RecurringJob.Trigger(id) or the scheduler processing a recurring job whose 'Job' hash field is missing or empty. Also reachable through IBackgroundJobFactory.TriggerRecurringJob directly.","commonSituations":"A recurring job was partially written to storage (interrupted write, custom storage bug). Manual deletion of the Job field. A migration or storage switch that dropped the payload. Triggering a job that was never fully created via AddOrUpdate.","solutions":["Recreate the recurring job with RecurringJob.AddOrUpdate to restore the serialized Job payload.","Remove the orphaned entry from the 'recurring-jobs' set if it is no longer needed (RecurringJob.RemoveIfExists).","If using a custom storage, verify that AddOrUpdate persists the Job field atomically alongside the set membership."],"exampleFix":"// before — triggering a corrupt entry\nRecurringJob.Trigger(\"broken-job\"); // throws\n\n// after — recreate then trigger\nRecurringJob.AddOrUpdate(\"broken-job\", () => Work(), Cron.Daily());\nRecurringJob.Trigger(\"broken-job\");","handlingStrategy":"try-catch","validationCode":"// Validate the recurring job has a Job payload before triggering\nvar job = connection.GetRecurringJobs().FirstOrDefault(j => j.Id == id);\nif (job?.Job == null) { /* recreate or skip */ }","typeGuard":null,"tryCatchPattern":"try { RecurringJob.Trigger(id); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"'Job' field\"))\n{\n    RecurringJob.AddOrUpdate(id, () => Work(), cron);\n}","preventionTips":["Always create recurring jobs through RecurringJob.AddOrUpdate so the Job payload is serialized.","Avoid manual storage edits to recurring-job entries.","Use custom storages that write the Job field atomically with set membership."],"tags":["recurring-job","storage-corruption","invalid-operation"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}