{"record":{"id":"fd216574620148f6","repo":"HangfireIO/Hangfire","slug":"could-not-get-a-value-of-the-job-parameter-name","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/Client/CreatingContext.cs","lineNumber":77,"sourceCode":"        /// <typeparam name=\"T\">The type of the parameter.</typeparam>\n        /// <param name=\"name\">The name of the parameter.</param>\n        /// <returns>The value of the given parameter if it exists or null otherwise.</returns>\n        /// \n        /// <exception cref=\"ArgumentNullException\">The <paramref name=\"name\"/> is null or empty.</exception>\n        /// <exception cref=\"InvalidOperationException\">Could not deserialize the parameter value to the type <typeparamref name=\"T\"/>.</exception>\n        public T GetJobParameter<T>(string name)\n        {\n            if (String.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name));\n\n            try\n            {\n                return Parameters.TryGetValue(name, out var parameter)\n                    ? (T)parameter\n                    : default(T);\n            }\n            catch (Exception ex) when (ex.IsCatchableExceptionType())\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":59,"sourceCodeEnd":82,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Client/CreatingContext.cs#L59-L82","documentation":"InvalidOperationException thrown by CreatingContext.GetJobParameter<T> when an existing parameter value cannot be cast to type T. The method looks up the parameter by name in the in-memory Parameters dictionary and attempts a direct cast (T)parameter; on InvalidCastException (or other cast-time exceptions filtered through IsCatchableExceptionType) it wraps the original as an inner exception. This typically means a parameter was stored with a different runtime type than requested, or the caller requested the wrong generic type.","triggerScenarios":"Calling context.GetJobParameter<int>(\"CurrentCulture\") when the stored value is a string; retrieving a parameter that CaptureCultureAttribute stored as a string name while expecting a CultureInfo; a custom filter writing a value of one type and another filter reading it as another.","commonSituations":"Mismatched types between a custom IClientFilter that writes a parameter and an IServerFilter that reads it; reading Hangfire's built-in CurrentCulture/CurrentUICulture parameters (stored as strings) with the wrong generic; version skew where a parameter's serialized representation changed.","solutions":["Match the generic type to the type used when SetJobParameter was called — Hangfire stores CurrentCulture as string, so use GetJobParameter<string>(\"CurrentCulture\").","Inspect the Parameters dictionary (or context.Items) before casting to verify the runtime type.","Coordinate type contracts between the writing filter (OnCreating) and reading filter (OnPerforming) with a shared helper or constant."],"exampleFix":"// before — type mismatch\nvar culture = context.GetJobParameter<CultureInfo>(\"CurrentCulture\");\n\n// after — Hangfire stores it as a string name\nvar cultureName = context.GetJobParameter<string>(\"CurrentCulture\");\nvar culture = cultureName != null ? CultureInfo.GetCultureInfo(cultureName) : CultureInfo.CurrentCulture;","handlingStrategy":"try-catch","validationCode":"var raw = context.Parameters.TryGetValue(name, out var p) ? p : null;\nif (raw != null && raw is T typed) return typed;\n// else handle type mismatch before calling GetJobParameter<T>","typeGuard":"public static bool CanGetAs<T>(CreatingContext ctx, string name)\n    => ctx.Parameters.TryGetValue(name, out var p) && p is T;","tryCatchPattern":"try { return context.GetJobParameter<T>(name); }\ncatch (InvalidOperationException ex) { /* inspect ex.InnerException (InvalidCastException), fix the requested type */ }","preventionTips":["Document the runtime type of every parameter your filters write, and read with that exact type.","Hangfire's built-in CurrentCulture/CurrentUICulture parameters are strings — always request GetJobParameter<string>.","Use a shared constants/types file so writers and readers agree on parameter contracts."],"tags":["invalid-cast","job-parameter","type-mismatch","client"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}