{"record":{"id":"f694e0da011d68b3","repo":"dotnet/reactive","slug":"argumentnullexception-observable-multiple","errorCode":null,"errorMessage":"ArgumentNullException","messagePattern":"ArgumentNullException","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs","lineNumber":838,"sourceCode":"\n        #endregion\n\n        #region + TakeUntil +\n\n        /// <summary>\n        /// Returns the elements from the source observable sequence until the other observable sequence produces an element.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence.</typeparam>\n        /// <typeparam name=\"TOther\">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>\n        /// <param name=\"source\">Source sequence to propagate elements for.</param>\n        /// <param name=\"other\">Observable sequence that terminates propagation of elements of the source sequence.</param>\n        /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"other\"/> is null.</exception>\n        public static IObservable<TSource> TakeUntil<TSource, TOther>(this IObservable<TSource> source, IObservable<TOther> other)\n        {\n            if (source == null)\n            {\n                throw new ArgumentNullException(nameof(source));\n            }\n\n            if (other == null)\n            {\n                throw new ArgumentNullException(nameof(other));\n            }\n\n            return s_impl.TakeUntil(source, other);\n        }\n\n        /// <summary>\n        /// Relays elements from the source observable sequence and calls the predicate after an\n        /// emission to check if the sequence should stop after that specific item.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source and result sequences.</typeparam>\n        /// <param name=\"source\">The source sequence to relay elements of.</param>\n        /// <param name=\"stopPredicate\">Called after each upstream item has been emitted with\n        /// that upstream item and should return <code>true</code> to indicate the sequence should","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs#L820-L856","documentation":"TakeUntil(source, other) validates both arguments and throws ArgumentNullException; at line 838 the failing check is 'source' being null. Rx throws eagerly so callers learn immediately that the query was built with an invalid sequence.","triggerScenarios":"Calling `.TakeUntil(other)` on a null source observable, e.g. `IObservable<int> src = null; src.TakeUntil(other);`.","commonSituations":"Building pipelines where the source comes from a nullable field, event registration that failed silently, or a factory that returns null instead of Observable.Empty.","solutions":["Ensure the source sequence is non-null before chaining TakeUntil","Substitute Observable.Empty<TSource>() for missing sources when a sequence is legitimately absent","Fix the upstream producer that returned null"],"exampleFix":"// before\nIObservable<Event> src = _bus?.Events;\nvar clipped = src.TakeUntil(stopSignal);\n// after\nIObservable<Event> src = _bus?.Events ?? Observable.Empty<Event>();\nvar clipped = src.TakeUntil(stopSignal);","handlingStrategy":"validation","validationCode":"if (source is null) throw new InvalidOperationException(\"source sequence required\"); // or source ??= Observable.Empty<TSource>();","typeGuard":"static bool CanTakeUntil<TSource,TOther>(IObservable<TSource> source, IObservable<TOther> other) => source is not null;","tryCatchPattern":"try { var q = source.TakeUntil(other); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source\") { /* fall back to empty sequence */ }","preventionTips":["Initialize observable sources at construction, never leave fields null","Return Observable.Empty from producers instead of null","Coalesce nullable sources before chaining operators"],"tags":["rx","null-check","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-15T23:17:13.987Z"}