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 ApplyStateContext.GetJobParameter when reading or deserializing a job parameter fails. Identical mechanism to PerformContext.GetJobParameter: the value is missing, mismatches T, or the storage read throws. This context is available during state application (filters, state handlers). InnerException holds the root cause.
Source
Thrown at src/Hangfire.Core/States/ApplyStateContext.cs:122
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
- Confirm the parameter is written before the state transition that reads it (e.g. set it in OnStateElection before ApplyState filters run).
- Match the generic type T to the type used when the parameter was stored.
- Guard the read with try/catch (InvalidOperationException) and use a sensible default for optional parameters.
Example fix
// before
var parentId = context.GetJobParameter<string>("ParentId"); // throws if unset
// after
string parentId;
try { parentId = context.GetJobParameter<string>("ParentId"); }
catch (InvalidOperationException) { parentId = null; } Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the parameter was set before the transition reads it 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
- Write parameters at enqueue time before any state filter reads them.
- Match the generic type between writer and reader.
- Guard optional reads with try/catch and a default.
When it happens
Trigger: Inside an IState/ElectState/ApplyState filter, calling context.GetJobParameter<T>(name) for a parameter that was never set, was set with an incompatible type, or whose storage read fails.
Common situations: A state filter reads a continuation or custom parameter that hasn't been written yet at that state-transition stage. Type mismatch between the setter (often in client code) and the filter's getter. Storage errors during the state-change transaction.
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/33040c522b2eb7f0.
Report an issue: GitHub.