dotnet/reactive · error · ArgumentNullException

source5

Error message

source5

What it means

The 14-source Zip overload validates source5 at line 873; null there throws ArgumentNullException with parameter name 'source5'. Rx performs eager validation in the public method before delegating to the internal implementation, so the exception is thrown synchronously at the call site.

Solutions

  1. Use Observable.Empty<TSource5>() in place of the null fifth argument.
  2. Fix the producer returning null for source5.
  3. Validate each source is non-null before the Zip call.
  4. Re-check argument order across the 14-source call.

Example fix

// before
var zipped = Observable.Zip(s1, s2, s3, s4, null, s6, ..., s14, selector);
// after
var zipped = Observable.Zip(s1, s2, s3, s4, s5 ?? Observable.Empty<TSource5>(), s6, ..., s14, selector);
Defensive patterns

Strategy: validation

Validate before calling

if (source5 == null) throw new ArgumentNullException(nameof(source5));

Type guard

static IObservable<T> NonNull<T>(IObservable<T> s) => s ?? Observable.Empty<T>();

Try / catch

try { var zipped = Observable.Zip(source1, ..., source5, ...); } catch (ArgumentNullException ex) when (ex.ParamName == "source5") { /* substitute default source or abort */ }

Prevention

When it happens

Trigger: Calling the 14-argument Observable.Zip with null as the fifth IObservable<TSource5> argument.

Common situations: An optional fifth stream passed as null instead of an empty observable, a failed stream-factory call on an error path, or argument misalignment during refactoring of the long parameter list.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/b1b8fdbc2c8a2519. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.Zip.cs:873

            if (source2 == null)
            {
                throw new ArgumentNullException(nameof(source2));
            }

            if (source3 == null)
            {
                throw new ArgumentNullException(nameof(source3));
            }

            if (source4 == null)
            {
                throw new ArgumentNullException(nameof(source4));
            }

            if (source5 == null)
            {
                throw new ArgumentNullException(nameof(source5));
            }

            if (source6 == null)
            {
                throw new ArgumentNullException(nameof(source6));
            }

            if (source7 == null)
            {
                throw new ArgumentNullException(nameof(source7));
            }

            if (source8 == null)
            {
                throw new ArgumentNullException(nameof(source8));
            }

            if (source9 == null)

View on GitHub (pinned to 94b5d5ab91)