{"record":{"id":"c054186204b3e806","repo":"HangfireIO/Hangfire","slug":"action","errorCode":null,"errorMessage":"action","messagePattern":"action","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Profiling/EmptyProfiler.cs","lineNumber":33,"sourceCode":"\nusing System;\n\nnamespace Hangfire.Profiling\n{\n    internal sealed class EmptyProfiler : IProfiler\n    {\n        internal static readonly IProfiler Instance = new EmptyProfiler();\n\n        private EmptyProfiler()\n        {\n        }\n\n        public TResult InvokeMeasured<TInstance, TResult>(\n            TInstance instance, \n            Func<TInstance, TResult> action,\n            Func<TInstance, string> messageFunc)\n        {\n            if (action == null) throw new ArgumentNullException(nameof(action));\n            return action(instance);\n        }\n    }\n}","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Profiling/EmptyProfiler.cs#L15-L37","documentation":"Thrown by EmptyProfiler.InvokeMeasured (internal) when the action argument is null. The profiler is a pass-through that immediately invokes action(instance), so a null delegate would NRE on the very next line.","triggerScenarios":"Calling EmptyProfiler.Instance.InvokeMeasured(instance, null, messageFunc) where the action delegate is null. Reached when Hangfire's profiling pipeline is handed a null measurement callback.","commonSituations":"A custom profiler or invocation wrapper forwards a null action; a refactor that built the action conditionally and left it null; test code exercising the profiler with a null lambda.","solutions":["Pass a non-null Func<TInstance, TResult> action to InvokeMeasured.","Guard the call site: throw a descriptive exception if the action is null before invoking.","Ensure the code constructing the measured action always supplies a real delegate."],"exampleFix":"// before\nprofiler.InvokeMeasured(instance, null, msg);\n\n// after\nprofiler.InvokeMeasured(instance, inst => DoMeasure(inst), msg);","handlingStrategy":"validation","validationCode":"if (action == null) throw new ArgumentNullException(nameof(action));\nreturn profiler.InvokeMeasured(instance, action, messageFunc);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a real delegate to InvokeMeasured.","Guard callers that build the action conditionally.","In tests, supply a concrete measurement function."],"tags":["hangfire","null-argument","argument-validation","profiling"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}