{"record":{"id":"6d644cb048786521","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-bufferboundaries-observable","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'bufferBoundaries')","messagePattern":"Value cannot be null\\. \\(Parameter 'bufferBoundaries'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs","lineNumber":153,"sourceCode":"        /// <summary>\n        /// Projects each element of an observable sequence into consecutive non-overlapping buffers.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>\n        /// <typeparam name=\"TBufferBoundary\">The type of the elements in the sequences indicating buffer boundary events.</typeparam>\n        /// <param name=\"source\">Source sequence to produce buffers over.</param>\n        /// <param name=\"bufferBoundaries\">Sequence of buffer boundary markers. The current buffer is closed and a new buffer is opened upon receiving a boundary marker.</param>\n        /// <returns>An observable sequence of buffers.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"bufferBoundaries\"/> is null.</exception>\n        public static IObservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IObservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)\n        {\n            if (source == null)\n            {\n                throw new ArgumentNullException(nameof(source));\n            }\n\n            if (bufferBoundaries == null)\n            {\n                throw new ArgumentNullException(nameof(bufferBoundaries));\n            }\n\n            return s_impl.Buffer(source, bufferBoundaries);\n        }\n\n        #endregion\n\n        #region + Catch +\n\n        /// <summary>\n        /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>\n        /// <typeparam name=\"TException\">The type of the exception to catch and handle. Needs to derive from <see cref=\"Exception\"/>.</typeparam>\n        /// <param name=\"source\">Source sequence.</param>\n        /// <param name=\"handler\">Exception handler function, producing another observable sequence.</param>\n        /// <returns>An observable sequence containing the source sequence's elements, followed by the elements produced by the handler's resulting observable sequence in case an exception occurred.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"handler\"/> is null.</exception>","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs#L135-L171","documentation":"The Buffer(source, bufferBoundaries) overload throws ArgumentNullException when the bufferBoundaries observable is null. The boundaries stream supplies the delimiters between buffers, so it is a required argument validated synchronously at the call site.","triggerScenarios":"Calling source.Buffer(boundaries) where the boundaries IObservable<TBufferBoundary> is null — e.g. a timer/tick stream never started, a merged boundary stream built from possibly-null inputs, or a null returned by a boundary-stream factory.","commonSituations":"Combining several boundary streams with a helper that returns null when all inputs are absent; event-driven boundary streams not yet wired (null field); config-driven boundary source missing so the factory returns null.","solutions":["Initialize or fix the boundary observable before the call.","Use Observable.Empty<TBufferBoundary>() (or Observable.Never<TBufferBoundary>()) when no boundaries should exist — Empty closes one final buffer, Never keeps the current buffer open.","Guard the call site so Buffer is only invoked with a non-null boundaries stream."],"exampleFix":"// before\nvar buffers = source.Buffer(maybeBoundaries); // throws if maybeBoundaries is null\n// after\nvar boundaries = maybeBoundaries ?? Observable.Never<long>();\nvar buffers = source.Buffer(boundaries);","handlingStrategy":"validation","validationCode":"ArgumentNullException.ThrowIfNull(boundaries);\nvar boundaries = maybeBoundaries ?? Observable.Never<TBufferBoundary>();","typeGuard":"bool HasBoundaries<TBufferBoundary>(IObservable<TBufferBoundary>? b) => b is not null;","tryCatchPattern":"try { var buffers = source.Buffer(boundaries); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"bufferBoundaries\") { /* supply Observable.Never<TBufferBoundary>() */ }","preventionTips":["Start boundary streams (timers, ticks, events) before composing Buffer.","When merging multiple boundary streams, use Observable.Merge which never returns null.","Validate configuration-driven boundary sources at startup."],"tags":["argument-null","rx","buffer","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"}