HangfireIO/Hangfire · error · ArgumentException

Display name is empty

Error message

Display name is empty

What it means

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.

Source

Thrown at src/Hangfire.Core/JobDisplayNameAttribute.cs:39

using System.Resources;
using Hangfire.Common;
using Hangfire.Dashboard;

namespace Hangfire
{
    /// <summary>
    /// Specifies a display name for a job method.
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
    public class JobDisplayNameAttribute : Attribute
    {
        private static readonly ConcurrentDictionary<Type, ResourceManager> _resourceManagerCache
            = new ConcurrentDictionary<Type, ResourceManager>();

        public JobDisplayNameAttribute(string displayName)
        {
            if (string.IsNullOrEmpty(displayName))
                throw new ArgumentException("Display name is empty", nameof(displayName));

            DisplayName = displayName;
        }

        /// <summary>
        /// Gets display name for the job.
        /// </summary>
        public string DisplayName { get; }

        /// <summary>
        /// Gets or sets resource type to localize <see cref="DisplayName"/> string.
        /// </summary>
        public Type ResourceType { get; set; }

        public virtual string Format(DashboardContext context, Job job)
        {
            var format = DisplayName;

View on GitHub (pinned to c236dd0f93)

Solutions

  1. Provide a non-empty display name string literal
  2. 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)
  3. Validate any dynamically-generated display name before applying the attribute

Example fix

// before
[JobDisplayName("")]
public void SendEmail(int userId) { }

// after
[JobDisplayName("Send Email to User {0}")]
public void SendEmail(int userId) { }
Defensive patterns

Strategy: validation

Validate before calling

// Validate at code review time - attribute arguments are compile-time constants
// Ensure [JobDisplayName("...")] always has a non-empty literal

Prevention

When it happens

Trigger: Decorating a method with [JobDisplayName(null)] or [JobDisplayName("")] or passing a variable that evaluated to null/empty at attribute application time.

Common situations: 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.

Related errors


AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13). Data as JSON: /api/errors/1f775424a79cbb49. Report an issue: GitHub.