{"record":{"id":"d2ed0a03d56c3b52","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-sources-d2ed0a","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'sources')","messagePattern":"Value cannot be null\\. \\(Parameter 'sources'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.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;\n\nnamespace System.Linq\n{\n    public static partial class EnumerableEx\n    {\n        /// <summary>\n        /// Concatenates the input sequences.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence with the elements of the source sequences concatenated.</returns>\n        public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<IEnumerable<TSource>> sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return ConcatCore(sources);\n        }\n\n        /// <summary>\n        /// Concatenates the input sequences.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"sources\">Source sequences.</param>\n        /// <returns>Sequence with the elements of the source sequences concatenated.</returns>\n        public static IEnumerable<TSource> Concat<TSource>(params IEnumerable<TSource>[] sources)\n        {\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return ConcatCore(sources);\n        }\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Ix.NET/Source/System.Interactive/System/Linq/Operators/Concat.cs#L2-L38","documentation":"The Concat overload Concat<TSource>(this IEnumerable<IEnumerable<TSource>> sources) throws ArgumentNullException with parameter name 'sources' when the outer sequence of sequences is null. Ix.NET validates arguments eagerly so the null is reported at the call site rather than during deferred enumeration. Pass an empty sequence to concatenate nothing.","triggerScenarios":"Calling sources.Concat() with a null outer enumerable, e.g. a batch list variable that was never initialized.","commonSituations":"A factory or deserializer returning null for an empty collection; a nullable field passed directly as the outer sequence; pipeline code where an earlier step produced null.","solutions":["Ensure the outer sequence is non-null; use Enumerable.Empty<IEnumerable<TSource>>() for no input.","Coalesce at the call site: (sources ?? Enumerable.Empty<IEnumerable<T>>()).Concat().","Fix the upstream producer to return an empty collection instead of null.","Enable nullable reference types so the compiler warns before the call."],"exampleFix":"// before\nvar result = ((IEnumerable<IEnumerable<int>>)null).Concat();\n// after\nvar result = (sources ?? Enumerable.Empty<IEnumerable<int>>()).Concat();","handlingStrategy":"validation","validationCode":"if (sources is null)\n    throw new ArgumentNullException(nameof(sources));\n// or coalesce:\nsources ??= Enumerable.Empty<IEnumerable<TSource>>();","typeGuard":"static bool IsUsableSources<TSource>(IEnumerable<IEnumerable<TSource>> s) => s != null;","tryCatchPattern":"try\n{\n    var result = sources.Concat();\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"sources\")\n{\n    var result = Enumerable.Empty<TSource>();\n}","preventionTips":["Producers of outer collections should return empty sequences, never null.","Coalesce nullable outer enumerables before passing to operators.","Configure deserializers to emit empty collections instead of null.","Enable nullable reference types to catch null arguments at compile time."],"tags":["csharp","null-argument","linq","ix-net","argument-validation"],"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"}