{"record":{"id":"ab7478dd0eab5035","repo":"dotnet/reactive","slug":"throw-new-argumentnullexception-nameof-provider","errorCode":null,"errorMessage":"throw new ArgumentNullException(nameof(provider))","messagePattern":"throw new ArgumentNullException\\(nameof\\(provider\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs","lineNumber":965,"sourceCode":"                    GetSourceExpression(sixteenth)\n                )\n            );\n        }\n\n#if !STABLE\n        /// <summary>\n        /// Subscribes to each observable sequence returned by the iteratorMethod in sequence and produces a Unit value on the resulting sequence for each step of the iteration.\n        /// </summary>\n        /// <param name=\"provider\">Query provider used to construct the <see cref=\"IQbservable{T}\"/> data source.</param>\n        /// <param name=\"iteratorMethod\">Iterator method that drives the resulting observable sequence.</param>\n        /// <returns>An observable sequence obtained by running the iterator and returning Unit values for each iteration step.</returns>\n        /// <exception cref=\"ArgumentNullException\">\n        /// <paramref name=\"iteratorMethod\" /> is null.</exception>\n        [Experimental]\n        public static IQbservable<Unit> Create(this IQbservableProvider provider, Expression<Func<IEnumerable<IObservable<object>>>> iteratorMethod)\n        {\n            if (provider == null)\n                throw new ArgumentNullException(nameof(provider));\n            if (iteratorMethod == null)\n                throw new ArgumentNullException(nameof(iteratorMethod));\n\n            return provider.CreateQuery<Unit>(\n                Expression.Call(\n                    null,\n                    new Func<IQbservableProvider, Expression<Func<IEnumerable<IObservable<object>>>>, IQbservable<Unit>>(Create).Method,\n                    Expression.Constant(provider, typeof(IQbservableProvider)),\n                    iteratorMethod\n                )\n            );\n        }\n#endif\n\n#if !STABLE\n        /// <summary>\n        /// Subscribes to each observable sequence returned by the iteratorMethod in sequence and returns the observable sequence of values sent to the observer given to the iteratorMethod.\n        /// </summary>","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs#L947-L983","documentation":"QbservableEx.Create(provider, iteratorMethod) requires an IQbservableProvider to build the remote query. A null provider is rejected immediately with ArgumentNullException named 'provider'. Rx throws eagerly so invalid queries fail at composition rather than at subscription time on the provider.","triggerScenarios":"Calling Qbservable.Create(null, iteratorMethod) — typically when the provider came from a null source.Provider, an uninitialized service locator, or a conditional expression like qbservable?.Provider.","commonSituations":"Chaining .Provider off a query built conditionally; DI container returning null for IQbservableProvider; using the extension before the queryable source was initialized in test scaffolding.","solutions":["Pass a valid IQbservableProvider, e.g. from an existing query's .Provider or Qbservable.Provider","Resolve the provider from your DI/ServiceProvider and verify registration is non-null","Guard the call site with a null check on the provider before invoking Create"],"exampleFix":"// before\nQbservable.Create(provider, iteratorMethod);\n// after\nif (provider == null) throw new InvalidOperationException(\"No IQbservableProvider configured\");\nQbservable.Create(provider, iteratorMethod);","handlingStrategy":"validation","validationCode":"if (provider == null)\n    throw new InvalidOperationException(\"IQbservableProvider is not configured\");","typeGuard":"bool HasProvider(IQbservableProvider p) => p is not null;","tryCatchPattern":"try\n{\n    var query = Qbservable.Create(provider, iteratorMethod);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"provider\")\n{\n    logger.LogError(ex, \"Provider was null when composing Create query\");\n}","preventionTips":["Register IQbservableProvider in DI and fail fast at startup if unresolved","Obtain providers from an existing query's .Provider rather than nullable variables","Never propagate ?. chains that silently yield null providers"],"tags":["argumentnull","rx","qbservable","create"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}