{"record":{"id":"b3aff3237a55a23a","repo":"HangfireIO/Hangfire","slug":"context-b3aff3","errorCode":null,"errorMessage":"context","messagePattern":"context","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Obsolete/RequestDispatcherContext.cs","lineNumber":53,"sourceCode":"            if (owinEnvironment == null) throw new ArgumentNullException(nameof(owinEnvironment));\n            if (uriMatch == null) throw new ArgumentNullException(nameof(uriMatch));\n\n            AppPath = appPath;\n            StatsPollingInterval = statsPollingInterval;\n            JobStorage = jobStorage;\n            OwinEnvironment = owinEnvironment;\n            UriMatch = uriMatch;\n        }\n\n        public string AppPath { get; }\n        public int StatsPollingInterval { get; }\n        public JobStorage JobStorage { get; }\n        public IDictionary<string, object> OwinEnvironment { get; } \n        public Match UriMatch { get; }\n\n        public static RequestDispatcherContext FromDashboardContext([NotNull] DashboardContext context)\n        {\n            if (context == null) throw new ArgumentNullException(nameof(context));\n\n            var owinContext = context as OwinDashboardContext;\n            if (owinContext == null)\n            {\n                throw new NotSupportedException($\"context must be of type '{nameof(OwinDashboardContext)}'\");\n            }\n            \n            return new RequestDispatcherContext(\n                owinContext.Options.AppPath,\n                owinContext.Options.StatsPollingInterval,\n                owinContext.Storage,\n                owinContext.Environment,\n                owinContext.UriMatch);\n        }\n    }\n}","sourceCodeStart":35,"sourceCodeEnd":69,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Obsolete/RequestDispatcherContext.cs#L35-L69","documentation":"Thrown as ArgumentNullException by the obsolete RequestDispatcherContext.FromDashboardContext factory when the 'context' DashboardContext argument is null. The factory casts the context to OwinDashboardContext to extract options, storage, environment, and uri match; a null context has nothing to read, so it is rejected at line 53.","triggerScenarios":"Calling RequestDispatcherContext.FromDashboardContext(null) — i.e. a RequestDispatcherWrapper (or custom caller) passes a null DashboardContext to the conversion factory, often because the dispatcher's Dispatch was invoked with no context or the upstream pipeline lost the reference.","commonSituations":"A custom IDashboardDispatcher or middleware that forwards a null context into RequestDispatcherWrapper.Dispatch; a test that exercises the wrapper without building a real DashboardContext; a bug in pipeline wiring where the context is conditionally null.","solutions":["Ensure any caller of FromDashboardContext (directly or via RequestDispatcherWrapper.Dispatch) supplies a non-null DashboardContext built from the current request.","Migrate away from RequestDispatcherWrapper/RequestDispatcherContext to the modern IDashboardDispatcher model that receives a DashboardContext directly.","Add a null guard in your dispatcher before calling the wrapper so the failure is reported at the true source."],"exampleFix":"// before\nwrapper.Dispatch(null);\n\n// after\nif (context == null) throw new ArgumentNullException(nameof(context));\nwrapper.Dispatch(context);","handlingStrategy":"validation","validationCode":"if (context == null) throw new ArgumentNullException(nameof(context));\nwrapper.Dispatch(context);","typeGuard":"// if (context is not DashboardContext) return;","tryCatchPattern":null,"preventionTips":["Guard against null context in any custom dispatcher before delegating.","Migrate to IDashboardDispatcher that receives a DashboardContext directly."],"tags":["argument-null","dashboard","context","obsolete"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}