{"record":{"id":"1f775424a79cbb49","repo":"HangfireIO/Hangfire","slug":"display-name-is-empty","errorCode":null,"errorMessage":"Display name is empty","messagePattern":"Display name is empty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/JobDisplayNameAttribute.cs","lineNumber":39,"sourceCode":"using System.Resources;\nusing Hangfire.Common;\nusing Hangfire.Dashboard;\n\nnamespace Hangfire\n{\n    /// <summary>\n    /// Specifies a display name for a job method.\n    /// </summary>\n    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]\n    public class JobDisplayNameAttribute : Attribute\n    {\n        private static readonly ConcurrentDictionary<Type, ResourceManager> _resourceManagerCache\n            = new ConcurrentDictionary<Type, ResourceManager>();\n\n        public JobDisplayNameAttribute(string displayName)\n        {\n            if (string.IsNullOrEmpty(displayName))\n                throw new ArgumentException(\"Display name is empty\", nameof(displayName));\n\n            DisplayName = displayName;\n        }\n\n        /// <summary>\n        /// Gets display name for the job.\n        /// </summary>\n        public string DisplayName { get; }\n\n        /// <summary>\n        /// Gets or sets resource type to localize <see cref=\"DisplayName\"/> string.\n        /// </summary>\n        public Type ResourceType { get; set; }\n\n        public virtual string Format(DashboardContext context, Job job)\n        {\n            var format = DisplayName;\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/JobDisplayNameAttribute.cs#L21-L57","documentation":"Thrown by the JobDisplayNameAttribute constructor when the displayName argument is null or empty. The attribute decorates a job method with a human-readable name shown in the dashboard; an empty name defeats its purpose.","triggerScenarios":"Decorating a method with [JobDisplayName(null)] or [JobDisplayName(\"\")] or passing a variable that evaluated to null/empty at attribute application time.","commonSituations":"A display name sourced from a resource lookup that returned null, a refactoring that left an empty string literal, or a code generation tool that emitted an empty display name.","solutions":["Provide a non-empty display name string literal","If using resource-based localization, set the ResourceType property and verify the resource key resolves to a non-empty value at the attribute level (the constructor still requires a non-empty DisplayName)","Validate any dynamically-generated display name before applying the attribute"],"exampleFix":"// before\n[JobDisplayName(\"\")]\npublic void SendEmail(int userId) { }\n\n// after\n[JobDisplayName(\"Send Email to User {0}\")]\npublic void SendEmail(int userId) { }","handlingStrategy":"validation","validationCode":"// Validate at code review time - attribute arguments are compile-time constants\n// Ensure [JobDisplayName(\"...\")] always has a non-empty literal","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide a meaningful non-empty display name literal in the attribute","Use static analysis / Roslyn analyzers to flag empty attribute arguments","For localized names, still provide a non-empty key string and set ResourceType separately"],"tags":["argument-exception","attribute","dashboard","validation","hangfire"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}