HangfireIO/Hangfire · error · ArgumentNullException

featureId

Error message

featureId

What it means

Thrown by JobStorage.HasFeature when the featureId parameter is null. HasFeature is a virtual method that returns false by default (base JobStorage); storage implementations override it to advertise capabilities. The base implementation guards against a null feature identifier.

Source

Thrown at src/Hangfire.Core/JobStorage.cs:121

        }

        public virtual IEnumerable<IBackgroundProcess> GetStorageWideProcesses()
        {
            return Enumerable.Empty<IBackgroundProcess>();
        }

        public virtual IEnumerable<IStateHandler> GetStateHandlers()
        {
            return Enumerable.Empty<IStateHandler>();
        }

        public virtual void WriteOptionsToLog(ILog logger)
        {
        }

        public virtual bool HasFeature([NotNull] string featureId)
        {
            if (featureId == null) throw new ArgumentNullException(nameof(featureId));
            return false;
        }
    }
}

View on GitHub (pinned to c236dd0f93)

Solutions

  1. Use constants from JobStorageFeatures (e.g., JobStorageFeatures.ProcessesInsteadOfComponents) rather than dynamic strings
  2. Validate the featureId is non-null before calling HasFeature
  3. In custom storage overrides, guard against null before delegating to base.HasFeature

Example fix

// before
if (storage.HasFeature(featureName)) // featureName is null

// after
if (!string.IsNullOrEmpty(featureName) && storage.HasFeature(featureName))
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(featureId))
    throw new ArgumentException("Feature ID must be non-empty.", nameof(featureId));
var supported = storage.HasFeature(featureId);

Type guard

!string.IsNullOrEmpty(featureId)

Prevention

When it happens

Trigger: Calling storage.HasFeature(null) or passing a variable for the featureId that resolved to null. Also triggered by internal Hangfire code if a feature ID constant is somehow null.

Common situations: Custom storage implementation calling base.HasFeature(null) in an override, or application code checking for a feature using a dynamic string that was null. Rare in practice since feature IDs are typically constants from JobStorageFeatures.

Related errors


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