{"record":{"id":"c8cc307471781903","repo":"dotnet/reactive","slug":"throw-new-argumentnullexception-nameof-other","errorCode":null,"errorMessage":"throw new ArgumentNullException(nameof(other));","messagePattern":"throw new ArgumentNullException\\(nameof\\(other\\)\\);","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Time.cs","lineNumber":1935,"sourceCode":"        /// <param name=\"timeoutDurationSelector\">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>\n        /// <param name=\"other\">Sequence to return in case of a timeout.</param>\n        /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"timeoutDurationSelector\"/> or <paramref name=\"other\"/> is null.</exception>\n        public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector, IObservable<TSource> other)\n        {\n            if (source == null)\n            {\n                throw new ArgumentNullException(nameof(source));\n            }\n\n            if (timeoutDurationSelector == null)\n            {\n                throw new ArgumentNullException(nameof(timeoutDurationSelector));\n            }\n\n            if (other == null)\n            {\n                throw new ArgumentNullException(nameof(other));\n            }\n\n            return s_impl.Timeout(source, timeoutDurationSelector, other);\n        }\n\n        /// <summary>\n        /// Applies a timeout policy to the observable sequence based on an initial timeout duration for the first element, and a timeout duration computed for each subsequent element.\n        /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence.</typeparam>\n        /// <typeparam name=\"TTimeout\">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>\n        /// <param name=\"source\">Source sequence to perform a timeout for.</param>\n        /// <param name=\"firstTimeout\">Observable sequence that represents the timeout for the first element.</param>\n        /// <param name=\"timeoutDurationSelector\">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>\n        /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"firstTimeout\"/> or <paramref name=\"timeoutDurationSelector\"/> is null.</exception>\n        public static IObservable<TSource> Timeout<TSource, TTimeout>(this IObservable<TSource> source, IObservable<TTimeout> firstTimeout, Func<TSource, IObservable<TTimeout>> timeoutDurationSelector)\n        {","sourceCodeStart":1917,"sourceCodeEnd":1953,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Time.cs#L1917-L1953","documentation":"The Timeout(source, timeoutDurationSelector, other) overload throws ArgumentNullException because the 'other' fallback sequence is null. This overload exists specifically to switch to 'other' on timeout, so it must be non-null. The check fires before any subscription, when the query is built.","triggerScenarios":"Calling source.Timeout(selector, other) with a null IObservable<TSource> fallback sequence.","commonSituations":"A fallback stream lazily created but never initialized; a method returning null instead of Observable.Empty; merging logic that passes an optional fallback straight through.","solutions":["Pass a non-null fallback such as Observable.Empty<TSource>() or Observable.Throw<TSource>(new TimeoutException())","If no fallback is wanted, use the (source, selector) overload which throws TimeoutException instead","Fix the producer that yields the null fallback stream"],"exampleFix":"// before\nsource.Timeout(selector, other)\n// after\nvar fallback = other ?? Observable.Empty<TSource>();\nsource.Timeout(selector, fallback)","handlingStrategy":"validation","validationCode":"var fallback = other ?? Observable.Empty<TSource>();\nvar result = source.Timeout(timeoutDurationSelector, fallback);","typeGuard":"static bool IsValidFallback<T>(IObservable<T> o) => o is not null;","tryCatchPattern":"try\n{\n    result = source.Timeout(selector, other);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"other\")\n{\n    result = source.Timeout(selector); // TimeoutException behavior instead of fallback\n}","preventionTips":["Normalize optional fallbacks with ?? Observable.Empty<T>()","Use the selector-only overload when no fallback is intended","Never return null from fallback-stream factories"],"tags":["argumentnull","reactive-extensions","fallback-sequence","argument-validation"],"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"}