HangfireIO/Hangfire · error · InvalidOperationException
Could not get a value of the job parameter `{name}`. See inn
Error message
Could not get a value of the job parameter `{name}`. See inner exception for details. What it means
Thrown by PerformContext.GetJobParameter when reading or deserializing a job parameter fails for any catchable reason — the parameter doesn't exist (value null), the stored value can't deserialize to T, or the storage read throws. The original error is preserved as InnerException. This is the server-side performer context.
Source
Thrown at src/Hangfire.Core/Server/PerformContext.cs:142
try
{
string value;
if (allowStale && BackgroundJob.ParametersSnapshot != null)
{
BackgroundJob.ParametersSnapshot.TryGetValue(name, out value);
}
else
{
value = Connection.GetJobParameter(BackgroundJob.Id, name);
}
return SerializationHelper.Deserialize<T>(value, SerializationOption.User);
}
catch (Exception ex) when (ex.IsCatchableExceptionType())
{
throw new InvalidOperationException(
$"Could not get a value of the job parameter `{name}`. See inner exception for details.", ex);
}
}
}
}
View on GitHub (pinned to c236dd0f93)
Solutions
- Ensure the parameter is set via context.SetJobParameter / SetJobParameter before reading it.
- Match the type T exactly to the type used when the parameter was written.
- Wrap GetJobParameter in try/catch (InvalidOperationException) and provide a default when the parameter is optional.
Example fix
// before
var retry = context.GetJobParameter<int>("RetryCount"); // throws if unset
// after
int retry;
try { retry = context.GetJobParameter<int>("RetryCount"); }
catch (InvalidOperationException) { retry = 0; } Defensive patterns
Strategy: try-catch
Validate before calling
// Check whether the parameter exists before deserializing var raw = context.Connection.GetJobParameter(context.BackgroundJob.Id, name); if (string.IsNullOrEmpty(raw)) return default;
Try / catch
T value;
try { value = context.GetJobParameter<T>(name); }
catch (InvalidOperationException) { value = default; } Prevention
- Always SetJobParameter for any parameter a job/filter will later read.
- Use matching types when writing and reading parameters.
- Guard optional-parameter reads with try/catch and a default.
When it happens
Trigger: Calling context.GetJobParameter<T>(name) inside a job or filter where the parameter was never set, was set with a different type, or the connection.GetJobParameter call fails. T must be deserializable from the stored user-serialized value.
Common situations: Reading a parameter that was never written (e.g. 'CoreBackgroundJobServerParameters' or a custom param). Type mismatch between writer and reader. Storage connectivity issue during parameter read. Corrupt serialized parameter.
Related errors
- Can't perform a background job with a null job.
- No dispatchers registered for the processing server.
- JobActivator returned NULL instance of the '{context.Backgro
- An exception occurred during performance of the job.
- Could not get a value of the job parameter `{name}`. See inn
AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13).
Data as JSON: /api/errors/0b8035daf4a5d450.
Report an issue: GitHub.