{"record":{"id":"33040c522b2eb7f0","repo":"HangfireIO/Hangfire","slug":"could-not-get-a-value-of-the-job-parameter-name-33040c","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/ApplyStateContext.cs","lineNumber":122,"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":104,"sourceCodeEnd":127,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/States/ApplyStateContext.cs#L104-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar parentId = context.GetJobParameter<string>(\"ParentId\"); // throws if unset\n\n// after\nstring parentId;\ntry { parentId = context.GetJobParameter<string>(\"ParentId\"); }\ncatch (InvalidOperationException) { parentId = null; }","handlingStrategy":"try-catch","validationCode":"// Verify the parameter was set before the transition reads it\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":["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."],"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"}