{"record":{"id":"c4efd42255cd2f21","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-leftdurationselector","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'leftDurationSelector')","messagePattern":"Value cannot be null\\. \\(Parameter 'leftDurationSelector'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.StandardSequenceOperators.cs","lineNumber":856,"sourceCode":"        /// <param name=\"rightDurationSelector\">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>\n        /// <param name=\"resultSelector\">A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence.</param>\n        /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"left\"/> or <paramref name=\"right\"/> or <paramref name=\"leftDurationSelector\"/> or <paramref name=\"rightDurationSelector\"/> or <paramref name=\"resultSelector\"/> is null.</exception>\n        public static IObservable<TResult> GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IObservable<TLeft> left, IObservable<TRight> right, Func<TLeft, IObservable<TLeftDuration>> leftDurationSelector, Func<TRight, IObservable<TRightDuration>> rightDurationSelector, Func<TLeft, IObservable<TRight>, TResult> resultSelector)\n        {\n            if (left == null)\n            {\n                throw new ArgumentNullException(nameof(left));\n            }\n\n            if (right == null)\n            {\n                throw new ArgumentNullException(nameof(right));\n            }\n\n            if (leftDurationSelector == null)\n            {\n                throw new ArgumentNullException(nameof(leftDurationSelector));\n            }\n\n            if (rightDurationSelector == null)\n            {\n                throw new ArgumentNullException(nameof(rightDurationSelector));\n            }\n\n            if (resultSelector == null)\n            {\n                throw new ArgumentNullException(nameof(resultSelector));\n            }\n\n            return s_impl.GroupJoin(left, right, leftDurationSelector, rightDurationSelector, resultSelector);\n        }\n\n        #endregion\n\n        #region + Join +","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.StandardSequenceOperators.cs#L838-L874","documentation":"GroupJoin threw ArgumentNullException because the leftDurationSelector delegate was null. The selector maps each left element to the observable defining its duration window; the public operator validates it synchronously.","triggerScenarios":"Calling left.GroupJoin(right, null, rightDurationSelector, resultSelector) — e.g. a window selector built conditionally that ended up null.","commonSituations":"Conditional window construction; forwarding optional method parameters; forgetting to replace a placeholder null after refactoring the join call.","solutions":["Supply a non-null duration selector, e.g. _ => Observable.Timer(TimeSpan.FromSeconds(5)) or _ => Observable.Empty<Unit>() for zero-duration.","Null-check the delegate before the call and fail with context.","Use Observable.Never<Unit>() if left elements should stay open indefinitely."],"exampleFix":"// before\nvar joined = left.GroupJoin(right, null, r => r.Window(), (l, rs) => ...);\n// after\nvar joined = left.GroupJoin(right, _ => Observable.Timer(TimeSpan.FromSeconds(5)), r => r.Window(), (l, rs) => ...);","handlingStrategy":"validation","validationCode":"if (leftDurationSelector == null)\n    leftDurationSelector = _ => Observable.Never<Unit>();","typeGuard":"bool HasLeftDuration<TLeft>(Func<TLeft, IObservable<Unit>>? f) => f is not null;","tryCatchPattern":"try\n{\n    var joined = left.GroupJoin(right, leftDurationSelector, rightDurationSelector, resultSelector);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"leftDurationSelector\")\n{\n    // use default window policy\n}","preventionTips":["Define a default left-window policy constant in your query-building layer.","Use Observable.Never<Unit>() or Observable.Empty<Unit>() instead of null to express window semantics.","Keep duration selectors as required parameters so the compiler catches omissions."],"tags":["null-argument","linq","reactive-extensions","groupjoin"],"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"}