{"record":{"id":"2bec72b776eddf4d","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-second-onerrorresumenext","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":"Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs","lineNumber":23,"sourceCode":"using System.Collections.Generic;\n\nnamespace System.Linq\n{\n    public static partial class EnumerableEx\n    {\n        /// <summary>\n        /// Creates a sequence that concatenates both given sequences, regardless of whether an error occurs.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"first\">First sequence.</param>\n        /// <param name=\"second\">Second sequence.</param>\n        /// <returns>Sequence concatenating the elements of both sequences, ignoring errors.</returns>\n        public static IEnumerable<TSource> OnErrorResumeNext<TSource>(this IEnumerable<TSource> first, IEnumerable<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 OnErrorResumeNextCore(new[] { first, second });\n        }\n\n        /// <summary>\n        /// Creates a sequence that concatenates the given sequences, regardless of whether an error occurs in any of the\n        /// sequences.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence concatenating the elements of the given sequences, ignoring errors.</returns>\n        public static IEnumerable<TSource> OnErrorResumeNext<TSource>(params IEnumerable<TSource>[] sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return OnErrorResumeNextCore(sources);\n        }","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Ix.NET/Source/System.Interactive/System/Linq/Operators/OnErrorResumeNext.cs#L5-L41","documentation":"OnErrorResumeNext(first, second) throws ArgumentNullException when the 'second' sequence is null. The library validates arguments eagerly so a bad call fails immediately rather than producing a confusing failure during deferred enumeration.","triggerScenarios":"Calling Enumerable.OnErrorResumeNext(first, null) where the second IEnumerable<TSource> parameter is null.","commonSituations":"Passing a sequence returned from a method that can return null (e.g. a lookup or dictionary miss), or chaining sequences where one source was conditionally built and left null.","solutions":["Pass a non-null second sequence; use Enumerable.Empty<TSource>() when there is nothing to concatenate.","Check the producing code path (config/lookup) that yielded a null sequence and fix it.","If null means 'no extra sequences', guard the call site: second != null ? src.OnErrorResumeNext(second) : src."],"exampleFix":"// before\nvar combined = first.OnErrorResumeNext(second); // second may be null\n// after\nvar combined = first.OnErrorResumeNext(second ?? Enumerable.Empty<int>());","handlingStrategy":"validation","validationCode":"if (second == null) throw new InvalidOperationException(\"second sequence must not be null\");\nvar combined = first.OnErrorResumeNext(second);","typeGuard":"static bool HasSecond(IEnumerable<int>? second) => second is not null;","tryCatchPattern":"try\n{\n    var combined = first.OnErrorResumeNext(second);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"second\")\n{\n    // handle missing sequence\n}","preventionTips":["Default nullable sequence parameters to Enumerable.Empty<T>() at boundaries.","Enable nullable reference types so null flows are caught at compile time.","Never pass results of lookups that can return null directly into operator overloads."],"tags":["null-reference","argument-validation","linq"],"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"}