{"record":{"id":"3f598c193e61bc1e","repo":"HangfireIO/Hangfire","slug":"could-not-get-a-value-of-the-job-parameter-name-3f598c","errorCode":null,"errorMessage":"Could not get a value of the job parameter `{name}`. See inner exception for details.","messagePattern":"Could not get a value of the job parameter `(.+?)`\\. See inner exception for details\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/States/ElectStateContext.cs","lineNumber":128,"sourceCode":"\n            try\n            {\n                string value;\n\n                if (allowStale && BackgroundJob.ParametersSnapshot != null)\n                {\n                    BackgroundJob.ParametersSnapshot.TryGetValue(name, out value);\n                }\n                else\n                {\n                    value = Connection.GetJobParameter(BackgroundJob.Id, name);                \n                }\n\n                return SerializationHelper.Deserialize<T>(value, SerializationOption.User);\n            }\n            catch (Exception ex)\n            {\n                throw new InvalidOperationException(\n                    $\"Could not get a value of the job parameter `{name}`. See inner exception for details.\", ex);\n            }\n        }\n    }\n}","sourceCodeStart":110,"sourceCodeEnd":133,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/States/ElectStateContext.cs#L110-L133","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar count = context.GetJobParameter<int>(\"Attempts\"); // throws if unset\n\n// after\nint count;\ntry { count = context.GetJobParameter<int>(\"Attempts\"); }\ncatch (InvalidOperationException) { count = 0; }","handlingStrategy":"try-catch","validationCode":"// Ensure parameters read during election were written at enqueue time\nvar raw = context.Connection.GetJobParameter(context.BackgroundJob.Id, name);\nif (string.IsNullOrEmpty(raw)) return default;","typeGuard":null,"tryCatchPattern":"T value;\ntry { value = context.GetJobParameter<T>(name); }\ncatch (InvalidOperationException) { value = default; }","preventionTips":["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."],"tags":["job-parameter","state","invalid-operation","filter"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}