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 ElectStateContext.GetJobParameter when reading or deserializing a job parameter fails. Same pattern as PerformContext and ApplyStateContext: missing value, type mismatch, or storage read failure, wrapped with the root cause as InnerException. This context is active during state election (before a state is applied).
Source
Thrown at src/Hangfire.Core/States/ElectStateContext.cs:128
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)
{
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 (SetJobParameter) at enqueue time, before any election filter reads it.
- Use the exact type T that was used to store the parameter.
- Catch InvalidOperationException around the read and apply a default for optional parameters.
Example fix
// before
var count = context.GetJobParameter<int>("Attempts"); // throws if unset
// after
int count;
try { count = context.GetJobParameter<int>("Attempts"); }
catch (InvalidOperationException) { count = 0; } Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure parameters read during election were written at enqueue time 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
- Set all election-time parameters when enqueuing the job.
- Use matching types for write and read of each parameter.
- Wrap optional reads in try/catch with a sensible default.
When it happens
Trigger: Inside an IState filter's OnStateElection or an IElectStateFilter, calling context.GetJobParameter<T>(name) for a parameter not yet present, stored with a different type, or unreadable from storage.
Common situations: A continuation or retry filter reads a parameter during election that the client hasn't written. Generic type mismatch between writer and reader. Storage connectivity issue during election.
Related errors
- Could not get a value of the job parameter `{name}`. See inn
- Could not get a value of the job parameter `{name}`. See inn
- Storage transaction class must inherit the JobStorageTransac
- Could not set parameter for a created 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/3f598c193e61bc1e.
Report an issue: GitHub.