HangfireIO/Hangfire · error · ArgumentNullException

featureId

Error message

featureId

What it means

The HasFeature method received a null featureId argument. This is a standard ArgumentNullException guard; the method looks up the feature ID string in an internal dictionary (_features) before delegating to the base implementation.

Source

Thrown at src/Hangfire.SqlServer/SqlServerStorage.cs:201

        public override IEnumerable<IBackgroundProcess> GetServerRequiredProcesses()
        {
            yield return _heartbeatProcess;
        }

        public override IEnumerable<IBackgroundProcess> GetStorageWideProcesses()
        {
            yield return new ExpirationManager(this, _options.InactiveStateExpirationTimeout, _options.JobExpirationCheckInterval);
            yield return new CountersAggregator(this, _options.CountersAggregateInterval);
        }

        public override void WriteOptionsToLog(ILog logger)
        {
            logger.Info($"Using the following options for SQL Server job storage: Queue poll interval: {_options.QueuePollInterval}.");
        }

        public override bool HasFeature(string featureId)
        {
            if (featureId == null) throw new ArgumentNullException(nameof(featureId));

            return _features.TryGetValue(featureId, out var isSupported) 
                ? isSupported
                : base.HasFeature(featureId);
        }

        public override string ToString()
        {
            const string canNotParseMessage = "<Connection string can not be parsed>";

            try
            {
                if (_connectionString == null)
                {
                    return "SQL Server (custom)";
                }

                var parts = _connectionString.Split(SemicolonSeparator, StringSplitOptions.RemoveEmptyEntries)

View on GitHub (pinned to c236dd0f93)

Solutions

  1. Pass a non-null feature identifier string such as "Job.Queue" or "Transaction.".
  2. Validate the feature ID before calling HasFeature if the source may be null.
  3. Use known Hangfire feature constant strings.

Example fix

// before
var supported = storage.HasFeature(featureName); // featureName is null
// after
var supported = !string.IsNullOrEmpty(featureName) && storage.HasFeature(featureName);
Defensive patterns

Strategy: validation

Validate before calling

string featureId = /* from logic or config */;
if (string.IsNullOrEmpty(featureId))
    return false; // or throw, depending on your logic

bool supported = storage.HasFeature(featureId);

Type guard

static bool IsQueryableFeature(string featureId) => !string.IsNullOrEmpty(featureId);

Prevention

When it happens

Trigger: Calling storage.HasFeature(null); passing a feature identifier variable that was never assigned or came from a null config value.

Common situations: Programmatic feature checks with uninitialized strings; feature-gating logic that receives null from an upstream source.

Related errors


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