{"record":{"id":"ec3eb26e72e38eda","repo":"HangfireIO/Hangfire","slug":"nameorconnectionstring-ec3eb2","errorCode":null,"errorMessage":"nameOrConnectionString","messagePattern":"nameOrConnectionString","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.SqlServer/SqlServerStorageExtensions.cs","lineNumber":46,"sourceCode":"\n        public static IGlobalConfiguration<SqlServerStorage> UseSqlServerStorage(\n            [NotNull] this IGlobalConfiguration configuration,\n            [NotNull] string nameOrConnectionString)\n        {\n            if (configuration == null) throw new ArgumentNullException(nameof(configuration));\n            if (nameOrConnectionString == null) throw new ArgumentNullException(nameof(nameOrConnectionString));\n\n            var storage = new SqlServerStorage(nameOrConnectionString);\n            return configuration.UseStorage(storage).UseSqlServerStorageCommonMetrics();\n        }\n\n        public static IGlobalConfiguration<SqlServerStorage> UseSqlServerStorage(\n            [NotNull] this IGlobalConfiguration configuration,\n            [NotNull] string nameOrConnectionString, \n            [NotNull] SqlServerStorageOptions options)\n        {\n            if (configuration == null) throw new ArgumentNullException(nameof(configuration));\n            if (nameOrConnectionString == null) throw new ArgumentNullException(nameof(nameOrConnectionString));\n            if (options == null) throw new ArgumentNullException(nameof(options));\n\n            var storage = new SqlServerStorage(nameOrConnectionString, options);\n            return configuration.UseStorage(storage).UseSqlServerStorageCommonMetrics();\n        }\n\n        public static IGlobalConfiguration<SqlServerStorage> UseSqlServerStorage(\n            [NotNull] this IGlobalConfiguration configuration,\n            [NotNull] Func<DbConnection> connectionFactory)\n        {\n            if (configuration == null) throw new ArgumentNullException(nameof(configuration));\n            if (connectionFactory == null) throw new ArgumentNullException(nameof(connectionFactory));\n\n            var storage = new SqlServerStorage(connectionFactory);\n            return configuration.UseStorage(storage).UseSqlServerStorageCommonMetrics();\n        }\n\n        public static IGlobalConfiguration<SqlServerStorage> UseSqlServerStorage(","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.SqlServer/SqlServerStorageExtensions.cs#L28-L64","documentation":"The UseSqlServerStorage(this IGlobalConfiguration, string, SqlServerStorageOptions) extension method received a null nameOrConnectionString argument. This is a standard ArgumentNullException guard for the connection-string parameter.","triggerScenarios":"Passing null as the nameOrConnectionString to the three-parameter UseSqlServerStorage overload; a config value that resolved to null.","commonSituations":"Reading a connection string name from IConfiguration that is absent; uninitialized variable; refactoring that removes the assignment.","solutions":["Ensure nameOrConnectionString is a non-null string (either a raw connection string or a config name).","Validate the value from configuration before passing, providing a fallback or error if missing."],"exampleFix":"// before\nvar conn = Configuration.GetValue<string>(\"Hangfire:ConnectionString\"); // null if missing\nconfig.UseSqlServerStorage(conn, options);\n// after\nvar conn = Configuration.GetConnectionString(\"Hangfire\")\n    ?? throw new InvalidOperationException(\"Hangfire connection string not configured\");\nconfig.UseSqlServerStorage(conn, options);","handlingStrategy":"validation","validationCode":"string nameOrConnectionString = Configuration.GetConnectionString(\"Hangfire\")\n    ?? throw new InvalidOperationException(\"Hangfire connection string not configured.\");\n\nconfig.UseSqlServerStorage(nameOrConnectionString, options);","typeGuard":"static bool IsValidConnectionStringArg(string value) => !string.IsNullOrWhiteSpace(value);","tryCatchPattern":null,"preventionTips":["Resolve and validate the connection string from configuration before calling UseSqlServerStorage.","Provide a clear error if the config value is missing.","Consider passing the full connection string directly to avoid name-resolution issues."],"tags":["argument-null","extension-method","connection-string","setup"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}