{"record":{"id":"2d9572a430a7754a","repo":"dotnet/reactive","slug":"observer-concatmany","errorCode":null,"errorMessage":"observer","messagePattern":"observer","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable/ConcatMany.cs","lineNumber":24,"sourceCode":"using System.Reactive.Disposables;\nusing System.Threading;\n\nnamespace System.Reactive.Linq.ObservableImpl\n{\n    internal sealed class ConcatMany<T> : IObservable<T>\n    {\n        private readonly IObservable<IObservable<T>> _sources;\n\n        internal ConcatMany(IObservable<IObservable<T>> sources)\n        {\n            _sources = sources;\n        }\n\n        public IDisposable Subscribe(IObserver<T> observer)\n        {\n            if (observer == null)\n            {\n                throw new ArgumentNullException(nameof(observer));\n            }\n\n            var parent = new ConcatManyOuterObserver(observer);\n\n            var d = _sources.SubscribeSafe(parent);\n            parent.OnSubscribe(d);\n\n            return parent;\n        }\n\n        internal sealed class ConcatManyOuterObserver : IObserver<IObservable<T>>, IDisposable\n        {\n            private readonly IObserver<T> _downstream;\n            private readonly ConcurrentQueue<IObservable<T>> _queue;\n            private readonly InnerObserver _innerObserver;\n\n            private SingleAssignmentDisposableValue _upstream;\n            private int _trampoline;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable/ConcatMany.cs#L6-L42","documentation":"Observable.ConcatMany's Subscribe validates its observer argument and throws ArgumentNullException when a null IObserver<T> is passed. This is standard Rx argument validation performed eagerly at subscription time rather than inside the observer pipeline.","triggerScenarios":"Calling Subscribe(null) directly on the ConcatMany observable, or a custom SubscribeOn/observer wrapper forwarding a null observer.","commonSituations":"Hand-rolled Rx pipelines where the observer is constructed dynamically and can be null; passing the result of a factory method that returned null.","solutions":["Pass a non-null IObserver<T> to Subscribe","Check the observer for null before calling Subscribe","Use Observer.Create<T>(...) to build a valid observer instead of passing null"],"exampleFix":"// before\nobservable.Subscribe(null);\n// after\nvar observer = Observer.Create<int>(x => Console.WriteLine(x));\nobservable.Subscribe(observer);","handlingStrategy":"type-guard","validationCode":"if (observer == null) throw new ArgumentNullException(nameof(observer));","typeGuard":"bool IsValidObserver<T>(IObserver<T> o) => o is not null;","tryCatchPattern":"try { observable.Subscribe(observer); }\ncatch (ArgumentNullException ex) { Log(ex); }","preventionTips":["Never pass a possibly-null observer; build one with Observer.Create","Validate factory results before subscribing","Enable nullable reference types to catch nulls at compile time"],"tags":["reactive","null-argument","subscribe"],"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"}