{"record":{"id":"a4aa30868ae15018","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-left","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'left')","messagePattern":"Value cannot be null\\. \\(Parameter 'left'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/GroupJoin.cs","lineNumber":18,"sourceCode":"﻿// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT License.\n// See the LICENSE file in the project root for more information. \n\nusing System.Collections.Generic;\nusing System.Reactive.Disposables;\nusing System.Reactive.Subjects;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        public static IAsyncObservable<TResult> GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IAsyncObservable<TLeft> left, IAsyncObservable<TRight> right, Func<TLeft, IAsyncObservable<TLeftDuration>> leftDurationSelector, Func<TRight, IAsyncObservable<TRightDuration>> rightDurationSelector, Func<TLeft, IAsyncObservable<TRight>, TResult> resultSelector)\n        {\n            if (left == null)\n                throw new ArgumentNullException(nameof(left));\n            if (right == null)\n                throw new ArgumentNullException(nameof(right));\n            if (leftDurationSelector == null)\n                throw new ArgumentNullException(nameof(leftDurationSelector));\n            if (rightDurationSelector == null)\n                throw new ArgumentNullException(nameof(rightDurationSelector));\n            if (resultSelector == null)\n                throw new ArgumentNullException(nameof(resultSelector));\n\n            return Create<TResult>(async observer =>\n            {\n                var subscriptions = new CompositeAsyncDisposable();\n\n                var (leftObserver, rightObserver, disposable) = AsyncObserver.GroupJoin(observer, subscriptions, leftDurationSelector, rightDurationSelector, resultSelector);\n\n                var leftSubscription = await left.SubscribeSafeAsync(leftObserver).ConfigureAwait(false);\n                await subscriptions.AddAsync(leftSubscription).ConfigureAwait(false);\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/GroupJoin.cs#L1-L36","documentation":"GroupJoin joins two async observables and needs the `left` source sequence to exist; it's the first parameter validated. Passing null throws ArgumentNullException immediately. The operator never handles a null source lazily — the check happens before Create is called.","triggerScenarios":"Calling `leftSource.GroupJoin(...)` where the receiver expression `left` is null (e.g. a null-returning factory), or invoking the static AsyncObservable.GroupJoin with null as the first argument.","commonSituations":"Async observable factory methods that return null instead of an empty sequence; DI-resolved stream dependencies that weren't registered; LINQ-style chains built conditionally where the seed sequence was never assigned.","solutions":["Ensure the left source is non-null before calling; replace null-returning factories with AsyncObservable.Empty<T>().","Null-check the source variable: `if (left == null) left = AsyncObservable.Empty<TLeft>();`","Fix DI/field initialization so the source observable is registered."],"exampleFix":"// before\nvar result = maybeLeft.GroupJoin(right, lds, rds, rs); // maybeLeft is null\n// after\nvar left = maybeLeft ?? AsyncObservable.Empty<TLeft>();\nvar result = left.GroupJoin(right, lds, rds, rs);","handlingStrategy":"validation","validationCode":"if (left is null) throw new ArgumentNullException(nameof(left));\n// or normalize before calling:\nleft ??= AsyncObservable.Empty<TLeft>();","typeGuard":"bool IsValidSource<T>(IAsyncObservable<T>? s) => s is not null;","tryCatchPattern":"try\n{\n    var result = left.GroupJoin(right, lds, rds, rs);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"left\")\n{\n    var result = AsyncObservable.Empty<TResult>();\n}","preventionTips":["Never let factory methods return null observables — return Empty instead.","Null-check stream dependencies resolved from DI before composing operators.","Enable nullable reference types to catch null sources at compile time."],"tags":["argparse","null-check","async-rx"],"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"}