{"record":{"id":"c28dd5620c0a24c7","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-second-sequenceequal","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'second')","messagePattern":"Value cannot be null\\. \\(Parameter 'second'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/SequenceEqual.cs","lineNumber":20,"sourceCode":"// 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.Threading;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        // TODO: Add SequenceEqual<T>(IAsyncObservable<T>, IAsyncEnumerable<T>).\n\n        public static IAsyncObservable<bool> SequenceEqual<TSource>(this IAsyncObservable<TSource> first, IAsyncObservable<TSource> second)\n        {\n            if (first == null)\n                throw new ArgumentNullException(nameof(first));\n            if (second == null)\n                throw new ArgumentNullException(nameof(second));\n\n            return CreateAsyncObservable<bool>.From(\n                first,\n                second,\n                static async (first, second, observer) =>\n                {\n                    var (firstObserver, secondObserver) = AsyncObserver.SequenceEqual<TSource>(observer);\n\n                    var firstTask = first.SubscribeSafeAsync(firstObserver);\n                    var secondTask = second.SubscribeSafeAsync(secondObserver);\n\n                    // REVIEW: Consider concurrent subscriptions.\n\n                    var d1 = await firstTask.ConfigureAwait(false);\n                    var d2 = await secondTask.ConfigureAwait(false);\n\n                    return StableCompositeAsyncDisposable.Create(d1, d2);\n                });","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/SequenceEqual.cs#L2-L38","documentation":"SequenceEqual compares two observables element-by-element; the second sequence is validated because the pairwise comparison is impossible without it. Fix: pass a non-null IAsyncObservable<TSource> for the second argument.","triggerScenarios":"Calling first.SequenceEqual(null) or first.SequenceEqual((IAsyncObservable<TSource>)null) where the right-hand sequence comes from a nullable source.","commonSituations":"Comparing against a sequence retrieved from a nullable API (config, cache, another operator's result); forgetting that a variable of reference type defaults to null.","solutions":["Pass a valid IAsyncObservable<TSource> as the second argument.","Default null to an empty sequence: second ?? AsyncObservable.Empty<TSource>().","Null-check the second sequence and handle the absent case explicitly.","Trace where the second sequence is produced and fix the producer returning null."],"exampleFix":"// before\nvar eq = left.SequenceEqual(maybeRight);\n// after\nvar eq = left.SequenceEqual(maybeRight ?? AsyncObservable.Empty<int>());","handlingStrategy":"validation","validationCode":"second ??= AsyncObservable.Empty<TSource>();","typeGuard":"static bool HasSequence<TSource>(IAsyncObservable<TSource>? s) => s is not null;","tryCatchPattern":"try { var eq = first.SequenceEqual(second); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"second\") { /* treat as not-equal or empty */ }","preventionTips":["Coalesce nullable right-hand sequences to AsyncObservable.Empty before comparing.","Keep expected/reference sequences in non-nullable fields initialized eagerly.","Add unit tests covering the null-second-sequence path."],"tags":["argument-null","sequenceequal","asyncrx"],"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"}